Skip to content

Commit b8830a4

Browse files
palidvhart
authored andcommitted
dell-laptop: Fix allocating & freeing SMI buffer page
This commit fix kernel crash when probing for rfkill devices in dell-laptop driver failed. Function free_page() was incorrectly used on struct page * instead of virtual address of SMI buffer. This commit also simplify allocating page for SMI buffer by using __get_free_page() function instead of sequential call of functions alloc_page() and page_address(). Signed-off-by: Pali Rohár <[email protected]> Acked-by: Michal Hocko <[email protected]> Cc: [email protected] Signed-off-by: Darren Hart <[email protected]>
1 parent 2e19f93 commit b8830a4

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

drivers/platform/x86/dell-laptop.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,6 @@ static const struct dmi_system_id dell_quirks[] __initconst = {
306306
};
307307

308308
static struct calling_interface_buffer *buffer;
309-
static struct page *bufferpage;
310309
static DEFINE_MUTEX(buffer_mutex);
311310

312311
static int hwswitch_state;
@@ -2068,12 +2067,11 @@ static int __init dell_init(void)
20682067
* Allocate buffer below 4GB for SMI data--only 32-bit physical addr
20692068
* is passed to SMI handler.
20702069
*/
2071-
bufferpage = alloc_page(GFP_KERNEL | GFP_DMA32);
2072-
if (!bufferpage) {
2070+
buffer = (void *)__get_free_page(GFP_KERNEL | GFP_DMA32);
2071+
if (!buffer) {
20732072
ret = -ENOMEM;
20742073
goto fail_buffer;
20752074
}
2076-
buffer = page_address(bufferpage);
20772075

20782076
ret = dell_setup_rfkill();
20792077

@@ -2135,7 +2133,7 @@ static int __init dell_init(void)
21352133
fail_backlight:
21362134
dell_cleanup_rfkill();
21372135
fail_rfkill:
2138-
free_page((unsigned long)bufferpage);
2136+
free_page((unsigned long)buffer);
21392137
fail_buffer:
21402138
platform_device_del(platform_device);
21412139
fail_platform_device2:

0 commit comments

Comments
 (0)