From patchwork Fri Jul 20 05:29:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lan,Tianyu" X-Patchwork-Id: 1219241 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 11D5BE007C for ; Fri, 20 Jul 2012 05:38:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752732Ab2GTFi0 (ORCPT ); Fri, 20 Jul 2012 01:38:26 -0400 Received: from mga02.intel.com ([134.134.136.20]:43833 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752516Ab2GTFiX (ORCPT ); Fri, 20 Jul 2012 01:38:23 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 19 Jul 2012 22:38:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.67,351,1309762800"; d="scan'208";a="174616634" Received: from lantianyu-ws.sh.intel.com (HELO localhost) ([10.239.13.17]) by orsmga002.jf.intel.com with ESMTP; 19 Jul 2012 22:38:21 -0700 From: Lan Tianyu To: lenb@kernel.org Cc: Lan Tianyu , linux-acpi@vger.kernel.org Subject: [Resend PATCH] ACPI/AC: add check the return value of power_supply_regiester() Date: Fri, 20 Jul 2012 13:29:16 +0800 Message-Id: <1342762156-22879-1-git-send-email-tianyu.lan@intel.com> X-Mailer: git-send-email 1.7.6.rc2.8.g28eb Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org In the ac.c, lack check return value of power_supply_register(). This may casue that acpi driver's add() ops was called successful while the device may be failed to be initalized. For example, some ugly bios may describe two ACADs in the same dsdt. They use the same name which will cause the second ACAD device can no be registered. And then power_supply_register() failed. But acpi driver's add() ops is called sucessfully. The acpi device also will receive acpi notification and cause oops. https://bugzilla.redhat.com/show_bug.cgi?id=772730 Signed-off-by: Lan Tianyu --- drivers/acpi/ac.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 6512b20..d1fcbc0 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c @@ -292,7 +292,9 @@ static int acpi_ac_add(struct acpi_device *device) ac->charger.properties = ac_props; ac->charger.num_properties = ARRAY_SIZE(ac_props); ac->charger.get_property = get_ac_property; - power_supply_register(&ac->device->dev, &ac->charger); + result = power_supply_register(&ac->device->dev, &ac->charger); + if (result) + goto end; printk(KERN_INFO PREFIX "%s [%s] (%s)\n", acpi_device_name(device), acpi_device_bid(device),