Skip to content

Commit ba0b09a

Browse files
jwrdegoedegregkh
authored andcommitted
platform/x86: x86-android-tablets: Fix use after free on platform_device_register() errors
commit 2fae3129c0c08e72b1fe93e61fd8fd203252094a upstream. x86_android_tablet_remove() frees the pdevs[] array, so it should not be used after calling x86_android_tablet_remove(). When platform_device_register() fails, store the pdevs[x] PTR_ERR() value into the local ret variable before calling x86_android_tablet_remove() to avoid using pdevs[] after it has been freed. Fixes: 5eba014 ("platform/x86: x86-android-tablets: Add support for instantiating platform-devs") Fixes: e2200d3f26da ("platform/x86: x86-android-tablets: Add gpio_keys support to x86_android_tablet_init()") Cc: [email protected] Reported-by: Aleksandr Burakov <[email protected]> Closes: https://lore.kernel.org/platform-driver-x86/[email protected]/ Signed-off-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/r/[email protected] [Xiangyu: Modified file path to backport this commit to fix CVE: CVE-2024-49986] Signed-off-by: Xiangyu Chen <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 486aeb5 commit ba0b09a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/platform/x86/x86-android-tablets.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1853,8 +1853,9 @@ static __init int x86_android_tablet_init(void)
18531853
for (i = 0; i < pdev_count; i++) {
18541854
pdevs[i] = platform_device_register_full(&dev_info->pdev_info[i]);
18551855
if (IS_ERR(pdevs[i])) {
1856+
ret = PTR_ERR(pdevs[i]);
18561857
x86_android_tablet_cleanup();
1857-
return PTR_ERR(pdevs[i]);
1858+
return ret;
18581859
}
18591860
}
18601861

0 commit comments

Comments
 (0)