From: Jesper Juhl Date: Fri, 23 Mar 2012 00:08:34 +0000 (+0100) Subject: drivers/platform/x86/amilo-rfkill.c::amilo_rfkill_probe() avoid NULL deref X-Git-Tag: v3.4-rc1~63^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=41603e9783a24c8c7cce548c0819bdc9e46a585b;p=profile%2Fivi%2Fkernel-x86-ivi.git drivers/platform/x86/amilo-rfkill.c::amilo_rfkill_probe() avoid NULL deref In drivers/platform/x86/amilo-rfkill.c::amilo_rfkill_probe() the call to dmi_first_match() may fail and return NULL. If it does return NULL, then we'll be dereferencing a NULL pointer in the rfkill_alloc() call where we do 'system_id->driver_data' --> KABOOM! Avoid that problem by testing for a NULL return value from dmi_first_match() and bailing out if it fails. I was a bit uncertain about what to return in the failure case. In the end I settled for -ENXIO as the most logical error to return. Signed-off-by: Jesper Juhl Signed-off-by: Matthew Garrett --- diff --git a/drivers/platform/x86/amilo-rfkill.c b/drivers/platform/x86/amilo-rfkill.c index 19170bb..a514bf6 100644 --- a/drivers/platform/x86/amilo-rfkill.c +++ b/drivers/platform/x86/amilo-rfkill.c @@ -97,9 +97,12 @@ static struct rfkill *amilo_rfkill_dev; static int __devinit amilo_rfkill_probe(struct platform_device *device) { + int rc; const struct dmi_system_id *system_id = dmi_first_match(amilo_rfkill_id_table); - int rc; + + if (!system_id) + return -ENXIO; amilo_rfkill_dev = rfkill_alloc(KBUILD_MODNAME, &device->dev, RFKILL_TYPE_WLAN,