From patchwork Thu Aug 13 03:12:05 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lin Ming X-Patchwork-Id: 40968 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 n7D3FtHp012622 for ; Thu, 13 Aug 2009 03:15:55 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752002AbZHMDPw (ORCPT ); Wed, 12 Aug 2009 23:15:52 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752082AbZHMDPw (ORCPT ); Wed, 12 Aug 2009 23:15:52 -0400 Received: from mga01.intel.com ([192.55.52.88]:33956 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751630AbZHMDPv (ORCPT ); Wed, 12 Aug 2009 23:15:51 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 12 Aug 2009 20:13:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.43,372,1246863600"; d="scan'208";a="716359617" Received: from minggr.sh.intel.com (HELO [10.239.13.35]) ([10.239.13.35]) by fmsmga001.fm.intel.com with ESMTP; 12 Aug 2009 20:19:01 -0700 Subject: [PATCH] acpi: fix null pointer deference of hardware_id string From: Lin Ming To: Len Brown Cc: thomas@m3y3r.de, linux-acpi , linux-next@vger.kernel.org Date: Thu, 13 Aug 2009 11:12:05 +0800 Message-Id: <1250133125.4044.19.camel@minggr.sh.intel.com> Mime-Version: 1.0 X-Mailer: Evolution 2.24.1 (2.24.1-2.fc10) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Lin Ming Date: Thu, 13 Aug 2009 11:04:47 +0800 Subject: [PATCH] acpi: fix null pointer deference of hardware_id string This regression was caused by commit ed44482 "ACPICA: Major update for acpi_get_object_info external interface" Don't need to set hardware_id string \0 terminated here, acpi_get_object_info already handles it. Tested-by: Thomas Meyer Signed-off-by: Lin Ming --- drivers/char/agp/hp-agp.c | 6 ++++-- drivers/pci/hotplug/acpiphp_ibm.c | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) -- 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 --git a/drivers/char/agp/hp-agp.c b/drivers/char/agp/hp-agp.c index 7bead4c..d83c4a8 100644 --- a/drivers/char/agp/hp-agp.c +++ b/drivers/char/agp/hp-agp.c @@ -492,8 +492,10 @@ zx1_gart_probe (acpi_handle obj, u32 depth, void *context, void **ret) status = acpi_get_object_info(handle, &info); if (ACPI_SUCCESS(status)) { /* TBD check _CID also */ - info->hardware_id.string[sizeof(info->hardware_id.length)-1] = '\0'; - match = (strcmp(info->hardware_id.string, "HWP0001") == 0); + if (info->valid & ACPI_VALID_HID) + match = !strcmp(info->hardware_id.string, "HWP0001"); + else + match = 0; kfree(info); if (match) { status = hp_acpi_csr_space(handle, &sba_hpa, &length); diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c index a9d926b..e7be66d 100644 --- a/drivers/pci/hotplug/acpiphp_ibm.c +++ b/drivers/pci/hotplug/acpiphp_ibm.c @@ -406,7 +406,6 @@ static acpi_status __init ibm_find_acpi_device(acpi_handle handle, __func__, status); return retval; } - info->hardware_id.string[sizeof(info->hardware_id.length) - 1] = '\0'; if (info->current_status && (info->valid & ACPI_VALID_HID) && (!strcmp(info->hardware_id.string, IBM_HARDWARE_ID1) ||