From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:41070 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752094AbbEBNDk (ORCPT ); Sat, 2 May 2015 09:03:40 -0400 Subject: Patch "compal-laptop: Check return value of power_supply_register" has been added to the 3.14-stable tree To: k.kozlowski@samsung.com, gregkh@linuxfoundation.org, sre@kernel.org Cc: , From: Date: Sat, 02 May 2015 15:03:21 +0200 Message-ID: <14305718019741@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org List-ID: This is a note to let you know that I've just added the patch titled compal-laptop: Check return value of power_supply_register to the 3.14-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: compal-laptop-check-return-value-of-power_supply_register.patch and it can be found in the queue-3.14 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >>From 1915a718b1872edffcb13e5436a9f7302d3d36f0 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 12 Mar 2015 08:44:00 +0100 Subject: compal-laptop: Check return value of power_supply_register From: Krzysztof Kozlowski commit 1915a718b1872edffcb13e5436a9f7302d3d36f0 upstream. 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 Fixes: 9be0fcb5ed46 ("compal-laptop: add JHL90, battery & hwmon interface") Signed-off-by: Sebastian Reichel Signed-off-by: Greg Kroah-Hartman --- drivers/platform/x86/compal-laptop.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/platform/x86/compal-laptop.c +++ b/drivers/platform/x86/compal-laptop.c @@ -1037,7 +1037,9 @@ static int compal_probe(struct platform_ /* 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); Patches currently in stable-queue which might be from k.kozlowski@samsung.com are queue-3.14/compal-laptop-check-return-value-of-power_supply_register.patch queue-3.14/power_supply-twl4030_madc-check-return-value-of-power_supply_register.patch queue-3.14/power_supply-lp8788-charger-fix-leaked-power-supply-on-probe-fail.patch