From: Pan Bian <bianpan2016@163.com>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Joel Stanley <joel@jms.id.au>
Cc: linux-kernel@vger.kernel.org, Pan Bian <bianpan2016@163.com>
Subject: fsi: use put_device to release resource on error path
Date: Wed, 17 Apr 2019 23:27:11 +0800 [thread overview]
Message-ID: <1555514831-124442-1-git-send-email-bianpan2016@163.com> (raw)
In the function fsi_slave_init, kfree is used to release slave if error
occurs during set smode. Some fields of slave will not be released.
Resulting in memory leak. Instread, put_device should be used to
correctly release resources.
Fixes: d1dcd6782576("fsi: Add cfam char devices")
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
drivers/fsi/fsi-core.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
index 2c31563..2bb6625 100644
--- a/drivers/fsi/fsi-core.c
+++ b/drivers/fsi/fsi-core.c
@@ -1056,8 +1056,7 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id)
dev_warn(&master->dev,
"can't set smode on slave:%02x:%02x %d\n",
link, id, rc);
- kfree(slave);
- return -ENODEV;
+ goto err_free;
}
if (master->link_config)
master->link_config(master, link,
--
2.7.4
reply other threads:[~2019-04-17 15:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1555514831-124442-1-git-send-email-bianpan2016@163.com \
--to=bianpan2016@163.com \
--cc=benh@kernel.crashing.org \
--cc=joel@jms.id.au \
--cc=linux-kernel@vger.kernel.org \
/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).