From: Nishka Dasgupta <nishkadg.linux@gmail.com>
To: jdelvare@suse.com, linux@roeck-us.net,
linux-hwmon@vger.kernel.org, eibach@gdsys.de
Cc: Nishka Dasgupta <nishkadg.linux@gmail.com>
Subject: [PATCH] hwmon: ads1015.c: Add of_node_put() before return
Date: Sat, 6 Jul 2019 18:53:57 +0530 [thread overview]
Message-ID: <20190706132357.3185-1-nishkadg.linux@gmail.com> (raw)
Each iteration of for_each_child_of_node puts the previous
node, but in the case of a return from the middle of the loop, there is
no put, thus causing a memory leak. Hence add an of_node_put before the
return in two places.
Issue found with Coccinelle.
Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
---
drivers/hwmon/ads1015.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/hwmon/ads1015.c b/drivers/hwmon/ads1015.c
index 3727a3762eb8..a0d62f6fa4b6 100644
--- a/drivers/hwmon/ads1015.c
+++ b/drivers/hwmon/ads1015.c
@@ -195,6 +195,7 @@ static int ads1015_get_channels_config_of(struct i2c_client *client)
if (pga > 6) {
dev_err(&client->dev, "invalid gain on %pOF\n",
node);
+ of_node_put(node);
return -EINVAL;
}
}
@@ -204,6 +205,7 @@ static int ads1015_get_channels_config_of(struct i2c_client *client)
if (data_rate > 7) {
dev_err(&client->dev,
"invalid data_rate on %pOF\n", node);
+ of_node_put(node);
return -EINVAL;
}
}
--
2.19.1
next reply other threads:[~2019-07-06 13:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-06 13:23 Nishka Dasgupta [this message]
2019-07-08 18:19 ` [PATCH] hwmon: ads1015.c: Add of_node_put() before return Guenter Roeck
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=20190706132357.3185-1-nishkadg.linux@gmail.com \
--to=nishkadg.linux@gmail.com \
--cc=eibach@gdsys.de \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux@roeck-us.net \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).