diff mbox

power_supply: 88pm860x_charger: do not pass NULL to power_supply_put

Message ID 1456689478-7318-1-git-send-email-colin.king@canonical.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Colin King Feb. 28, 2016, 7:57 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

In the case where power_supply_get_by_name returns NULL the current
error return path calls power_supply_put with a NULL psy which will
cause a null pointer dereference.  Avoid this with an immediate
return.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/power/88pm860x_charger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sebastian Reichel March 3, 2016, 2:21 p.m. UTC | #1
Hi,

On Sun, Feb 28, 2016 at 07:57:58PM +0000, Colin King wrote:
> In the case where power_supply_get_by_name returns NULL the current
> error return path calls power_supply_put with a NULL psy which will
> cause a null pointer dereference.  Avoid this with an immediate
> return.

Thanks, queued.

-- Sebastian
diff mbox

Patch

diff --git a/drivers/power/88pm860x_charger.c b/drivers/power/88pm860x_charger.c
index 297e72d..2b82e44 100644
--- a/drivers/power/88pm860x_charger.c
+++ b/drivers/power/88pm860x_charger.c
@@ -435,7 +435,7 @@  static irqreturn_t pm860x_temp_handler(int irq, void *data)
 
 	psy = power_supply_get_by_name(pm860x_supplied_to[0]);
 	if (!psy)
-		goto out;
+		return IRQ_HANDLED;
 	ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_TEMP, &temp);
 	if (ret)
 		goto out;