From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: gregkh@linuxfoundation.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org, arnd@arndb.de
Subject: Re: [PATCH] misc: fastrpc: fix memory leak
Date: Wed, 29 Apr 2020 22:02:59 -0700 [thread overview]
Message-ID: <20200430050259.GB2166963@builder.lan> (raw)
In-Reply-To: <20200429152951.18504-1-srinivas.kandagatla@linaro.org>
On Wed 29 Apr 08:29 PDT 2020, Srinivas Kandagatla wrote:
> if misc_register() fails, previously allocated data is left without freeing,
> this could result in memory leak.
s/could/will/
>
> So fix it!
>
As Markus pointed out, a Fixes: tag would be in order to make sure this
is backported properly.
PS: although unlikely, if of_platform_populate() where to fail we're
leaking both the contet and the misc device.
Regards,
Bjorn
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---
> drivers/misc/fastrpc.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> index e3e085e33d46..9065d3e71ff7 100644
> --- a/drivers/misc/fastrpc.c
> +++ b/drivers/misc/fastrpc.c
> @@ -1613,8 +1613,10 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
> domains[domain_id]);
> data->miscdev.fops = &fastrpc_fops;
> err = misc_register(&data->miscdev);
> - if (err)
> + if (err) {
> + kfree(data);
> return err;
> + }
>
> kref_init(&data->refcount);
>
> --
> 2.21.0
>
next prev parent reply other threads:[~2020-04-30 5:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-29 15:29 [PATCH] misc: fastrpc: fix memory leak Srinivas Kandagatla
2020-04-30 5:02 ` Bjorn Andersson [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-04-29 20:40 Markus Elfring
2019-07-04 16:25 Jorge Ramirez-Ortiz
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=20200430050259.GB2166963@builder.lan \
--to=bjorn.andersson@linaro.org \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=srinivas.kandagatla@linaro.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).