From: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
To: jorge.ramirez-ortiz@linaro.org, gregkh@linuxfoundation.org,
arnd@arndb.de, srinivas.kandagatla@linaro.org
Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org
Subject: [PATCH 2/5] misc: fastrpc: fix memory leak from miscdev->name
Date: Fri, 13 Sep 2019 17:25:29 +0200 [thread overview]
Message-ID: <20190913152532.24484-3-jorge.ramirez-ortiz@linaro.org> (raw)
In-Reply-To: <20190913152532.24484-1-jorge.ramirez-ortiz@linaro.org>
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Fix a memory leak in miscdev->name by using devm_variant
Orignally reported by kmemleak:
[<ffffff80088b74d8>] kmemleak_alloc+0x50/0x84
[<ffffff80081e015c>] __kmalloc_track_caller+0xe8/0x168
[<ffffff8008371ab0>] kvasprintf+0x78/0x100
[<ffffff8008371c6c>] kasprintf+0x50/0x74
[<ffffff8008507f2c>] fastrpc_rpmsg_probe+0xd8/0x20c
[<ffffff80086b63b4>] rpmsg_dev_probe+0xa8/0x148
[<ffffff80084de50c>] really_probe+0x208/0x248
[<ffffff80084de2dc>] driver_probe_device+0x98/0xc0
[<ffffff80084dec6c>] __device_attach_driver+0x9c/0xac
[<ffffff80084dca8c>] bus_for_each_drv+0x60/0x8c
[<ffffff80084de64c>] __device_attach+0x8c/0x100
[<ffffff80084de6e0>] device_initial_probe+0x20/0x28
[<ffffff80084dcbd0>] bus_probe_device+0x34/0x7c
[<ffffff80084da32c>] device_add+0x420/0x498
[<ffffff80084da680>] device_register+0x24/0x2c
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
drivers/misc/fastrpc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 8903388993d3..bc03500bfe60 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -1599,8 +1599,8 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
}
data->miscdev.minor = MISC_DYNAMIC_MINOR;
- data->miscdev.name = kasprintf(GFP_KERNEL, "fastrpc-%s",
- domains[domain_id]);
+ data->miscdev.name = devm_kasprintf(rdev, GFP_KERNEL, "fastrpc-%s",
+ domains[domain_id]);
data->miscdev.fops = &fastrpc_fops;
err = misc_register(&data->miscdev);
if (err)
--
2.23.0
next prev parent reply other threads:[~2019-09-13 15:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-13 15:25 [PATCH 0/5] misc: fastrpc: fixes and map/unmap support Jorge Ramirez-Ortiz
2019-09-13 15:25 ` [PATCH 1/5] misc: fastrpc: add mmap/unmap support Jorge Ramirez-Ortiz
2019-09-13 15:25 ` Jorge Ramirez-Ortiz [this message]
2019-09-18 6:34 ` [PATCH 2/5] misc: fastrpc: fix memory leak from miscdev->name Bjorn Andersson
2019-09-13 15:25 ` [PATCH 3/5] misc: fastrpc: do not interrupt kernel calls Jorge Ramirez-Ortiz
2019-09-13 15:25 ` [PATCH 4/5] misc: fastrpc: handle interrupted contexts Jorge Ramirez-Ortiz
2019-09-13 15:25 ` [PATCH 5/5] misc: fastrpc: revert max init file size back to 2MB 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=20190913152532.24484-3-jorge.ramirez-ortiz@linaro.org \
--to=jorge.ramirez-ortiz@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).