From: Lixin Wang <alan.1.wang@nokia-sbell.com>
To: Wolfram Sang <wsa@the-dreams.de>
Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
Lixin Wang <alan.1.wang@nokia-sbell.com>
Subject: [PATCH] i2c: core: decrease reference count of device node in i2c_unregister_device
Date: Mon, 27 Nov 2017 15:06:55 +0800 [thread overview]
Message-ID: <1511766415-3732-1-git-send-email-alan.1.wang@nokia-sbell.com> (raw)
Reference count of device node was increased in of_i2c_register_device,
but without decreasing it in i2c_unregister_device. Then the dynamically
added device node will never be released.
Fix this by adding the of_node_put.
Signed-off-by: Lixin Wang <alan.1.wang@nokia-sbell.com>
---
drivers/i2c/i2c-core-base.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 56e4658..b76adf9 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -808,8 +808,10 @@ EXPORT_SYMBOL_GPL(i2c_new_device);
*/
void i2c_unregister_device(struct i2c_client *client)
{
- if (client->dev.of_node)
+ if (client->dev.of_node) {
of_node_clear_flag(client->dev.of_node, OF_POPULATED);
+ of_node_put(client->dev.of_node);
+ }
if (ACPI_COMPANION(&client->dev))
acpi_device_clear_enumerated(ACPI_COMPANION(&client->dev));
device_unregister(&client->dev);
--
2.6.2
next reply other threads:[~2017-11-27 7:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-27 7:06 Lixin Wang [this message]
2017-11-27 18:21 ` [PATCH] i2c: core: decrease reference count of device node in i2c_unregister_device Wolfram Sang
2017-11-29 8:06 ` Wang, Alan 1. (NSB - CN/Hangzhou)
2018-01-15 23:02 ` Wolfram Sang
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=1511766415-3732-1-git-send-email-alan.1.wang@nokia-sbell.com \
--to=alan.1.wang@nokia-sbell.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wsa@the-dreams.de \
/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).