platform/x86: android-platform: deref after free in x86_android_tablet_init() fix
Subsystems (2)
PATCH 1/1 platform/x86: android-platform: deref after free in x86_android_tablet_init() fix
No upstream commit exists for this commit.
Pointer '&pdevs[i]' is dereferenced at x86_android_tablet_init() after the referenced memory was deallocated by calling function 'x86_android_tablet_cleanup()'.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/platform/x86/x86-android-tablets.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/platform/x86/x86-android-tablets.c +2 -1
@@ -1853,8 +1853,9 @@ static __init int x86_android_tablet_init(void)for (i =0 ; i < pdev_count; i++) { pdevs[i] =platform_device_register_full (&dev_info->pdev_info[i]);if (IS_ERR (pdevs[i])) { +int ret =PTR_ERR (pdevs[i]);x86_android_tablet_cleanup (); -return PTR_ERR (pdevs[i]); +return ret; } }
Signature · 1 line
2.25.1
Hans de Goede
NAKHi,
Thank you for your patch.
Quoted 1 line · Aleksandr Burakov
No upstream commit exists for this commit.
Right, which is bad, especially since the upstream code actually still has this bug.
NACK.
Note that upstream in drivers/platform/x86/x86-android-tablets/core.c the same issue is also present around line 447:
pdevs[pdev_count] = platform_device_register_data(&pdev->dev, "gpio-keys",
PLATFORM_DEVID_AUTO,
&pdata, sizeof(pdata));
if (IS_ERR(pdevs[pdev_count])) {
x86_android_tablet_remove(pdev);
return PTR_ERR(pdevs[pdev_count]);
}
pdev_count++;Please submit a fix for both issues upstream, once that has been merged you can submit a backport with a proper upstream commit reference.
Regards,
Hans
Quoted 28 lines
Pointer '&pdevs[i]' is dereferenced at
x86_android_tablet_init()after the referenced memory was deallocated by calling function 'x86_android_tablet_cleanup()'.Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes 5eba0141206e ("platform/x86: x86-android-tablets: Add support for instantiating platform-devs")Signed-off-by Aleksandr Burakov <[email protected]>--- drivers/platform/x86/x86-android-tablets.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/platform/x86/x86-android-tablets.c +2
-1@@ -1853,8 +1853,9 @@ static __init int x86_android_tablet_init(void)for (i =0 ; i < pdev_count; i++) { pdevs[i] =platform_device_register_full (&dev_info->pdev_info[i]);if (IS_ERR (pdevs[i])) { +int ret =PTR_ERR (pdevs[i]);x86_android_tablet_cleanup (); -return PTR_ERR (pdevs[i]); +return ret; } }
Quoted 3 lines · Aleksandr Burakov
No upstream commit exists for this commit.
Pointer '&pdevs[i]' is dereferenced at
x86_android_tablet_init()
s/at/in.
Quoted 2 lines
after the referenced memory was deallocated by calling function '
x86_android_tablet_cleanup()'.
No quotes around a function name the 1st time, and here they are
the 2nd time. Please be consistent...
Quoted 13 lines
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes 5eba0141206e ("platform/x86: x86-android-tablets: Add support for instantiating platform-devs")Signed-off-by Aleksandr Burakov <[email protected]>--- drivers/platform/x86/x86-android-tablets.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/platform/x86/x86-android-tablets.c +0
-0
drivers/platform/x86/x86-android-tablets.c static __init int x86_android_tablet_init(void) · line 1856
Quoted 4 lines
drivers/platform/x86/x86-android-tablets.c +1
-0@@ -1853,8 +1853,9 @@ static __init int x86_android_tablet_init(void)for (i =0 ; i < pdev_count; i++) { pdevs[i] =platform_device_register_full (&dev_info->pdev_info[i]);if (IS_ERR (pdevs[i])) { +int ret =PTR_ERR (pdevs[i]);
Need an empty line after the declartion, BTW...
drivers/platform/x86/x86-android-tablets.c static __init int x86_android_tablet_init(void) · line 1860
Quoted 5 lines
drivers/platform/x86/x86-android-tablets.c +1
-1x86_android_tablet_cleanup (); -return PTR_ERR (pdevs[i]); +return ret; } }
MBR, Sergey