From patchwork Tue Aug 17 00:58:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jin Dongming X-Patchwork-Id: 119834 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o7H0uvS3003596 for ; Tue, 17 Aug 2010 00:57:50 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753990Ab0HQA5t (ORCPT ); Mon, 16 Aug 2010 20:57:49 -0400 Received: from fgwmail7.fujitsu.co.jp ([192.51.44.37]:41727 "EHLO fgwmail7.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753803Ab0HQA5s (ORCPT ); Mon, 16 Aug 2010 20:57:48 -0400 Received: from m1.gw.fujitsu.co.jp ([10.0.50.71]) by fgwmail7.fujitsu.co.jp (Fujitsu Gateway) with ESMTP id o7H0vkIn001734 (envelope-from jin.dongming@np.css.fujitsu.com); Tue, 17 Aug 2010 09:57:47 +0900 Received: from smail (m1 [127.0.0.1]) by outgoing.m1.gw.fujitsu.co.jp (Postfix) with ESMTP id CEC933266C4; Tue, 17 Aug 2010 09:57:46 +0900 (JST) Received: from s1.gw.fujitsu.co.jp (s1.gw.fujitsu.co.jp [10.0.50.91]) by m1.gw.fujitsu.co.jp (Postfix) with ESMTP id 914821EF082; Tue, 17 Aug 2010 09:57:46 +0900 (JST) Received: from s1.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s1.gw.fujitsu.co.jp (Postfix) with ESMTP id 708331DB8059; Tue, 17 Aug 2010 09:57:46 +0900 (JST) Received: from m004.s.css.fujitsu.com (m004.s.css.fujitsu.com [10.23.4.34]) by s1.gw.fujitsu.co.jp (Postfix) with ESMTP id 2621B1DB8052; Tue, 17 Aug 2010 09:57:46 +0900 (JST) Received: from m004.css.fujitsu.com (m004 [127.0.0.1]) by m004.s.css.fujitsu.com (Postfix) with ESMTP id 0CBE550EBC9; Tue, 17 Aug 2010 09:57:46 +0900 (JST) Received: from [127.0.0.1] (unknown [10.124.102.46]) by m004.s.css.fujitsu.com (Postfix) with ESMTP id C9F5F50EBC6; Tue, 17 Aug 2010 09:57:45 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v1.5.1 Message-ID: <4C69DEA5.1020902@np.css.fujitsu.com> Date: Tue, 17 Aug 2010 09:58:13 +0900 From: Jin Dongming User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; ja; rv:1.9.2.7) Gecko/20100713 Thunderbird/3.1.1 MIME-Version: 1.0 To: Huang Ying CC: Randy Dunlap , Stephen Rothwell , Andi Kleen , Hidetoshi Seto , ACPI , LKLM Subject: [PATCH 4/4] [Patch-next] ACPI, APEI, HEST Fix the unsuitable usage of platform_data. Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 17 Aug 2010 00:57:50 +0000 (UTC) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index 385a605..b35c622 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -302,7 +302,7 @@ static int __devinit ghes_probe(struct platform_device *ghes_dev) struct ghes *ghes = NULL; int rc = -EINVAL; - generic = ghes_dev->dev.platform_data; + generic = *(struct acpi_hest_generic **)(ghes_dev->dev.platform_data); if (!generic->enabled) return -ENODEV; diff --git a/drivers/acpi/apei/hest.c b/drivers/acpi/apei/hest.c index 343168d..5a65e2a 100644 --- a/drivers/acpi/apei/hest.c +++ b/drivers/acpi/apei/hest.c @@ -137,20 +137,29 @@ static int hest_parse_ghes_count(struct acpi_hest_header *hest_hdr, void *data) static int hest_parse_ghes(struct acpi_hest_header *hest_hdr, void *data) { - struct acpi_hest_generic *generic; + void **platform_data; struct platform_device *ghes_dev; struct ghes_arr *ghes_arr = data; int rc; if (hest_hdr->type != ACPI_HEST_TYPE_GENERIC_ERROR) return 0; - generic = (struct acpi_hest_generic *)hest_hdr; - if (!generic->enabled) + + platform_data = kmalloc(sizeof(void *), GFP_KERNEL); + if (!platform_data) + return -ENOMEM; + + *platform_data = hest_hdr; + if (!((struct acpi_hest_generic *)*platform_data)->enabled) return 0; + ghes_dev = platform_device_alloc("GHES", hest_hdr->source_id); - if (!ghes_dev) + if (!ghes_dev) { + kfree(platform_data); return -ENOMEM; - ghes_dev->dev.platform_data = generic; + } + + ghes_dev->dev.platform_data = platform_data; rc = platform_device_add(ghes_dev); if (rc) goto err;