LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Alexey Khoroshilov <khoroshilov@ispras.ru>
To: Sebastian Reichel <sre@kernel.org>,
	Mike Looijmans <mike.looijmans@topic.nl>
Cc: Alexey Khoroshilov <khoroshilov@ispras.ru>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	ldv-project@linuxtesting.org, Julia Lawall <julia.lawall@lip6.fr>,
	sil2review@lists.osadl.org
Subject: [PATCH] power: supply: ltc2941-battery-gauge: Release device_node in ltc294x_i2c_probe()
Date: Sun, 29 Apr 2018 01:35:55 +0300	[thread overview]
Message-ID: <1524954955-22107-1-git-send-email-khoroshilov@ispras.ru> (raw)

There is of_node_get(client->dev.of_node) in ltc294x_i2c_probe(),
but these is no of_node_put() somethere in the driver.

The patch adds one on error and normal paths.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
 drivers/power/supply/ltc2941-battery-gauge.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/power/supply/ltc2941-battery-gauge.c b/drivers/power/supply/ltc2941-battery-gauge.c
index 4f129bb4c972..7854a89b3332 100644
--- a/drivers/power/supply/ltc2941-battery-gauge.c
+++ b/drivers/power/supply/ltc2941-battery-gauge.c
@@ -481,7 +481,7 @@ static int ltc294x_i2c_probe(struct i2c_client *client,
 	if (ret < 0) {
 		dev_err(&client->dev,
 			"Could not find lltc,resistor-sense in devicetree\n");
-		return ret;
+		goto err_node_put;
 	}
 	info->r_sense = r_sense;
 
@@ -511,7 +511,7 @@ static int ltc294x_i2c_probe(struct i2c_client *client,
 		if (ret < 0) {
 			dev_err(&client->dev,
 				"Could not read status register\n");
-			return ret;
+			goto err_node_put;
 		}
 		if (status & LTC2941_REG_STATUS_CHIP_ID)
 			info->id = LTC2941_ID;
@@ -550,19 +550,25 @@ static int ltc294x_i2c_probe(struct i2c_client *client,
 	ret = ltc294x_reset(info, prescaler_exp);
 	if (ret < 0) {
 		dev_err(&client->dev, "Communication with chip failed\n");
-		return ret;
+		goto err_node_put;
 	}
 
 	info->supply = power_supply_register(&client->dev, &info->supply_desc,
 					     &psy_cfg);
 	if (IS_ERR(info->supply)) {
 		dev_err(&client->dev, "failed to register ltc2941\n");
-		return PTR_ERR(info->supply);
+		ret = PTR_ERR(info->supply);
+		goto err_node_put;
 	} else {
 		schedule_delayed_work(&info->work, LTC294X_WORK_DELAY * HZ);
 	}
 
+	of_node_put(np);
 	return 0;
+
+err_node_put:
+	of_node_put(np);
+	return ret;
 }
 
 static void ltc294x_i2c_shutdown(struct i2c_client *client)
-- 
2.7.4

             reply	other threads:[~2018-04-28 22:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-28 22:35 Alexey Khoroshilov [this message]
2018-05-01 12:39 ` Sebastian Reichel
2018-05-08 19:16   ` Alexey Khoroshilov
2018-07-06 17:04     ` Sebastian Reichel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1524954955-22107-1-git-send-email-khoroshilov@ispras.ru \
    --to=khoroshilov@ispras.ru \
    --cc=julia.lawall@lip6.fr \
    --cc=ldv-project@linuxtesting.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mike.looijmans@topic.nl \
    --cc=sil2review@lists.osadl.org \
    --cc=sre@kernel.org \
    --subject='Re: [PATCH] power: supply: ltc2941-battery-gauge: Release device_node in ltc294x_i2c_probe()' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).