Message ID | 1249606433.7301.23.camel@minggr.sh.intel.com (mailing list archive) |
---|---|
State | RFC, archived |
Headers | show |
Hi, On Friday 07 August 2009 02:53:53 Lin Ming wrote: > On Fri, 2009-08-07 at 03:41 +0800, Bartlomiej Zolnierkiewicz wrote: > > From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> > > Subject: [PATCH] acpi: fix acpi_device_{install,remove}_notify_handler() for _HID-less devices > > Hi, > > The patch in -mm tree titled > "acpi-fix-null-bug-for-hid-uid-string-2.patch" > has fixed this regression. > Would you please give it a try? > > The patch attached below. > > Subject: acpi: fix NULL bug for HID/UID string > From: Hugh Dickins <hugh.dickins@tiscali.co.uk> > > acpi_device->pnp.hardware_id and unique_id are now allocated pointers, > replacing the previous arrays. acpi_device_install_notify_handler() > oopsed on the NULL hid when probing the video device, and perhaps other > uses are vulnerable too. So initialize those pointers to empty strings > when there is no hid or uid. Also, free hardware_id and unique_id when > when acpi_device is going to be freed. > > Signed-off-by: Hugh Dickins <hugh.dickins@tiscali.co.uk> > Signed-off-by: Lin Ming <ming.m.lin@intel.com> > Cc: Valdis Kletnieks <Valdis.Kletnieks@vt.edu> > Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Hugh's patch also fixes the problem and I like it more than mine version (BTW mmotm still contains older acpi-fix-null-bug-for-hid-uid-string.patch not acpi-fix-null-bug-for-hid-uid-string-2.patch). Andrew, could mmotm be somehow integrated with -next (the above bug was fixed in mmotm two weeks ago already)? If you're worried about affecting -next's quality, worry not, it really can't be much worse than it is now (at least we would have all outstanding patches really in the one place).. Thanks, Bart -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff -puN drivers/acpi/scan.c~acpi-fix-null-bug-for-hid-uid-string-2 drivers/acpi/scan.c --- a/drivers/acpi/scan.c~acpi-fix-null-bug-for-hid-uid-string-2 +++ a/drivers/acpi/scan.c @@ -309,6 +309,10 @@ static void acpi_device_release(struct d struct acpi_device *acpi_dev = to_acpi_device(dev); kfree(acpi_dev->pnp.cid_list); + if (acpi_dev->flags.hardware_id) + kfree(acpi_dev->pnp.hardware_id); + if (acpi_dev->flags.unique_id) + kfree(acpi_dev->pnp.unique_id); kfree(acpi_dev); } @@ -1132,8 +1136,9 @@ static void acpi_device_set_id(struct ac strcpy(device->pnp.hardware_id, hid); device->flags.hardware_id = 1; } - } else - device->pnp.hardware_id = NULL; + } + if (!device->flags.hardware_id) + device->pnp.hardware_id = ""; if (uid) { device->pnp.unique_id = ACPI_ALLOCATE_ZEROED(strlen (uid) + 1); @@ -1141,8 +1146,9 @@ static void acpi_device_set_id(struct ac strcpy(device->pnp.unique_id, uid); device->flags.unique_id = 1; } - } else - device->pnp.unique_id = NULL; + } + if (!device->flags.unique_id) + device->pnp.unique_id = ""; if (cid_list || cid_add) { struct acpica_device_id_list *list; @@ -1357,10 +1363,8 @@ acpi_add_single_object(struct acpi_devic end: if (!result) *child = device; - else { - kfree(device->pnp.cid_list); - kfree(device); - } + else + acpi_device_release(&device->dev); return result; }