From patchwork Thu Aug 6 22:57:56 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 39705 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n76MxLoi000974 for ; Thu, 6 Aug 2009 22:59:23 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756495AbZHFW7Q (ORCPT ); Thu, 6 Aug 2009 18:59:16 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756491AbZHFW7Q (ORCPT ); Thu, 6 Aug 2009 18:59:16 -0400 Received: from smtp1.linux-foundation.org ([140.211.169.13]:56658 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756495AbZHFW7P (ORCPT ); Thu, 6 Aug 2009 18:59:15 -0400 Received: from imap1.linux-foundation.org (imap1.linux-foundation.org [140.211.169.55]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id n76MvvKZ015737 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 6 Aug 2009 15:57:58 -0700 Received: from localhost.localdomain (localhost [127.0.0.1]) by imap1.linux-foundation.org (8.13.5.20060308/8.13.5/Debian-3ubuntu1.1) with ESMTP id n76MvuCr024266; Thu, 6 Aug 2009 15:57:56 -0700 Message-Id: <200908062257.n76MvuCr024266@imap1.linux-foundation.org> Subject: [patch 9/9] acpi: fix NULL bug for HID/UID string To: lenb@kernel.org Cc: linux-acpi@vger.kernel.org, akpm@linux-foundation.org, ming.m.lin@intel.com, Valdis.Kletnieks@vt.edu, hugh.dickins@tiscali.co.uk From: akpm@linux-foundation.org Date: Thu, 06 Aug 2009 15:57:56 -0700 X-Spam-Status: No, hits=-3.511 required=5 tests=AWL, BAYES_00, OSDL_HEADER_SUBJECT_BRACKETED X-Spam-Checker-Version: SpamAssassin 3.2.4-osdl_revision__1.47__ X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.13 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Lin Ming acpi_device->pnp.hardware_id and unique_id are now allocated pointer. If it's NULL, return "\0" for acpi_device_hid and acpi_device_uid. Also, free hardware_id and unique_id when acpi_device is going to be freed. Cc: Valdis Kletnieks Cc: Hugh Dickins Cc: Len Brown Signed-off-by: Lin Ming Signed-off-by: Andrew Morton --- drivers/acpi/scan.c | 4 ++++ include/acpi/acpi_bus.h | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff -puN drivers/acpi/scan.c~acpi-fix-null-bug-for-hid-uid-string drivers/acpi/scan.c --- a/drivers/acpi/scan.c~acpi-fix-null-bug-for-hid-uid-string +++ a/drivers/acpi/scan.c @@ -309,6 +309,8 @@ static void acpi_device_release(struct d struct acpi_device *acpi_dev = to_acpi_device(dev); kfree(acpi_dev->pnp.cid_list); + kfree(acpi_dev->pnp.hardware_id); + kfree(acpi_dev->pnp.unique_id); kfree(acpi_dev); } @@ -1359,6 +1361,8 @@ end: *child = device; else { kfree(device->pnp.cid_list); + kfree(device->pnp.hardware_id); + kfree(device->pnp.unique_id); kfree(device); } diff -puN include/acpi/acpi_bus.h~acpi-fix-null-bug-for-hid-uid-string include/acpi/acpi_bus.h --- a/include/acpi/acpi_bus.h~acpi-fix-null-bug-for-hid-uid-string +++ a/include/acpi/acpi_bus.h @@ -186,8 +186,8 @@ struct acpi_device_pnp { #define acpi_device_bid(d) ((d)->pnp.bus_id) #define acpi_device_adr(d) ((d)->pnp.bus_address) -#define acpi_device_hid(d) ((d)->pnp.hardware_id) -#define acpi_device_uid(d) ((d)->pnp.unique_id) +#define acpi_device_hid(d) ((d)->pnp.hardware_id ? (d)->pnp.hardware_id : "\0") +#define acpi_device_uid(d) ((d)->pnp.unique_id ? (d)->pnp.unique_id : "\0") #define acpi_device_name(d) ((d)->pnp.device_name) #define acpi_device_class(d) ((d)->pnp.device_class)