Message ID | 1425976046-20973-3-git-send-email-k.kozlowski@samsung.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org> X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 28D21BF440 for <patchwork-linux-arm@patchwork.kernel.org>; Tue, 10 Mar 2015 08:32:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4E9142024F for <patchwork-linux-arm@patchwork.kernel.org>; Tue, 10 Mar 2015 08:32:19 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7870C2022D for <patchwork-linux-arm@patchwork.kernel.org>; Tue, 10 Mar 2015 08:32:18 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YVFWU-0004Vc-62; Tue, 10 Mar 2015 08:28:18 +0000 Received: from mailout4.w1.samsung.com ([210.118.77.14]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YVFWP-0004PL-Pu for linux-arm-kernel@lists.infradead.org; Tue, 10 Mar 2015 08:28:15 +0000 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NKZ004WCMCXFO00@mailout4.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Tue, 10 Mar 2015 08:31:46 +0000 (GMT) X-AuditID: cbfec7f5-b7fc86d0000066b7-09-54feaa6ef0aa Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 8E.EF.26295.E6AAEF45; Tue, 10 Mar 2015 08:25:18 +0000 (GMT) Received: from AMDC1943.digital.local ([106.116.151.171]) by eusync4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NKZ0033KM64IB70@eusync4.samsung.com>; Tue, 10 Mar 2015 08:27:47 +0000 (GMT) From: Krzysztof Kozlowski <k.kozlowski@samsung.com> To: Sebastian Reichel <sre@kernel.org>, Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>, David Woodhouse <dwmw2@infradead.org>, "Rafael J. Wysocki" <rjw@rjwysocki.net>, Len Brown <lenb@kernel.org>, Jiri Kosina <jkosina@suse.cz>, David Herrmann <dh.herrmann@googlemail.com>, Cezary Jackiewicz <cezary.jackiewicz@gmail.com>, Darren Hart <dvhart@infradead.org>, Support Opensource <support.opensource@diasemi.com>, Milo Kim <milo.kim@ti.com>, Linus Walleij <linus.walleij@linaro.org>, Samuel Ortiz <sameo@linux.intel.com>, Lee Jones <lee.jones@linaro.org>, linux-arm-kernel@lists.infradead.org, Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>, x86@kernel.org, Daniel Mack <daniel@zonque.org>, Haojian Zhuang <haojian.zhuang@gmail.com>, Robert Jarzmik <robert.jarzmik@free.fr>, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-input@vger.kernel.org, platform-driver-x86@vger.kernel.org, patches@opensource.wolfsonmicro.com, ac100@lists.launchpad.net, linux-tegra@vger.kernel.org, devel@driverdev.osuosl.org Subject: [PATCH v6 02/22] compal-laptop: Check return value of power_supply_register Date: Tue, 10 Mar 2015 09:27:06 +0100 Message-id: <1425976046-20973-3-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1425976046-20973-1-git-send-email-k.kozlowski@samsung.com> References: <1425976046-20973-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAAyWReUiTcRjH/e099mot3qbpi5DQMDLxTKGHkAoE/UEQRdIfmubSoYZT2dQ0 gsSK8MhrpqGilsq88pqSpk4xZ9lUbB6kbYYXeWteiZbm9L/P8zwf+H7hYQihirRmwiKiJbII cbiINiO1+59HHSMq931chptpSOtf40HplxQSEv8tkJA1s0pAW98uH0qGLCH5rQtkVigIGKy5 DDn1VtBaUELC4pwr9Ccu8eHnlgZBy+QyDdl/lTxQqtMRNEyPUjC2vk3B0McCGjZedSNI2syj 4X23gQ/K3RoSdJ3Fh/LyAQ2GrxoaqtrmCOjT6ijIWzIHbQoF2tZoKK6fQtD+4hsBqobXBOzU TVPXbXH5ujOeUH8icXrNBoVb8gx8PJuh4GNVuT1uqEyisX60jcYrAwN8XNh7G6tKn2JNqp7E 85l7NF5Vj9C4ceQlidMaK9EtS18zj2BJeFisROZ8NdAsNHUkl4pSn4hba3ROQDOmyciU4Vh3 brFORx6zJTc4UUsnIzNGyJYh7o9+h388pPG4+alqntGiWTdOpSw9sixYDcPtrs7xjQeCXUBc /+QTI5uzd7nFsVZkZJI9z+V2TB6xgPXmCjuqiOM4G663R0EZ2ZTF3Obm+FEN4aFj0P1GGUhQ jEwq0RlJTFCU/EGI9JKTXCyVx0SEOAVFShvQ8aO3mlFZz5UuxDJIdFLw3W/fR0iJY+Xx0i7E MYTIQqBJP1wJgsXxjyWyyPuymHCJvAvxGFPrBBRiFxb4IXfFfcrhx7qjd/sbfX5T/4WbK/RD ve7XqRv3GhUmswcqolh0MDhnshs9HhvdlJ1nuzdZFJB12hAgrucFbOUkaHuK8tUZTR7xFzsd 3GLv+DTtWW1fe+QfVxEz1plmZ+PlZwhUjGjU53y9zw4z+c+r9e/8Ez1rveI9Fc8sRKQ8VOxq T8jk4v9KrEJrxgIAAA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150310_012814_047267_2B314F57 X-CRM114-Status: GOOD ( 10.24 ) X-Spam-Score: -5.0 (-----) Cc: Krzysztof Kozlowski <k.kozlowski@samsung.com>, stable@vger.kernel.org, Kyungmin Park <kyungmin.park@samsung.com>, Pavel Machek <pavel@ucw.cz>, Thomas Gleixner <tglx@linutronix.de>, Marek Szyprowski <m.szyprowski@samsung.com> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP |
diff --git a/drivers/platform/x86/compal-laptop.c b/drivers/platform/x86/compal-laptop.c index eb9885e7fb0e..bceb30b539f3 100644 --- a/drivers/platform/x86/compal-laptop.c +++ b/drivers/platform/x86/compal-laptop.c @@ -1036,7 +1036,9 @@ static int compal_probe(struct platform_device *pdev) /* Power supply */ initialize_power_supply_data(data); - power_supply_register(&compal_device->dev, &data->psy); + err = power_supply_register(&compal_device->dev, &data->psy); + if (err < 0) + goto remove; platform_set_drvdata(pdev, data);
The return value of power_supply_register() call was not checked and even on error probe() function returned 0. If registering failed then during unbind the driver tried to unregister power supply which was not actually registered. This could lead to memory corruption because power_supply_unregister() unconditionally cleans up given power supply. Fix this by checking return status of power_supply_register() call. In case of failure, clean up sysfs entries and fail the probe. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Fixes: 9be0fcb5ed46 ("compal-laptop: add JHL90, battery & hwmon interface") Cc: <stable@vger.kernel.org> --- Changes since previous submission: 1. Add Darren's ack. http://lkml.iu.edu/hypermail/linux/kernel/1503.0/01897.html --- drivers/platform/x86/compal-laptop.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)