All of lore.kernel.org
 help / color / mirror / Atom feed
* Patch "compal-laptop: Check return value of power_supply_register" has been added to the 3.19-stable tree
@ 2015-05-02 12:57 gregkh
  0 siblings, 0 replies; only message in thread
From: gregkh @ 2015-05-02 12:57 UTC (permalink / raw)
  To: k.kozlowski, gregkh, sre; +Cc: stable, stable-commits


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.19-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.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


>From 1915a718b1872edffcb13e5436a9f7302d3d36f0 Mon Sep 17 00:00:00 2001
From: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Date: Thu, 12 Mar 2015 08:44:00 +0100
Subject: compal-laptop: Check return value of power_supply_register

From: Krzysztof Kozlowski <k.kozlowski@samsung.com>

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 <k.kozlowski@samsung.com>
Fixes: 9be0fcb5ed46 ("compal-laptop: add JHL90, battery & hwmon interface")
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 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
@@ -1036,7 +1036,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.19/compal-laptop-fix-leaking-hwmon-device.patch
queue-3.19/compal-laptop-check-return-value-of-power_supply_register.patch
queue-3.19/power_supply-twl4030_madc-check-return-value-of-power_supply_register.patch
queue-3.19/power_supply-ipaq_micro_battery-fix-leaking-workqueue.patch
queue-3.19/power_supply-lp8788-charger-fix-leaked-power-supply-on-probe-fail.patch
queue-3.19/power_supply-ipaq_micro_battery-check-return-values-in-probe.patch

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-05-02 12:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-02 12:57 Patch "compal-laptop: Check return value of power_supply_register" has been added to the 3.19-stable tree gregkh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.