Skip to contentSkip to conversation

Patch "compal-laptop: Check return value of power_supply_register" has been added to the 3.19-stable tree

PATCH [email protected] 1 participant 1 message May 2, 2015

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

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 <[email protected]> know about it.

Quoted 1 line

From 1915a718b1872edffcb13e5436a9f7302d3d36f0 Mon Sep 17 00:00:00 2001

From: Krzysztof Kozlowski <[email protected]>
Date: Thu, 12 Mar 2015 08:44:00 +0100
Subject: compal-laptop: Check return value of power_supply_register

From: Krzysztof Kozlowski <[email protected]>

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.

Fixes 9be0fcb5ed46 ("compal-laptop: add JHL90, battery & hwmon interface")
---
 drivers/platform/x86/compal-laptop.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/platform/x86/compal-laptop.c +3 -1
@@ -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 [email protected] 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