* [PATCH] octeontx2-af: Fix memory leak of object buf
@ 2021-03-23 12:32 Colin King
2021-03-24 7:07 ` Sunil Kovvuri
2021-03-24 19:40 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2021-03-23 12:32 UTC (permalink / raw)
To: Sunil Goutham, Linu Cherian, Geetha sowjanya, Jerin Jacob,
hariprasad, Subbaraya Sundeep, David S . Miller, Jakub Kicinski,
Rakesh Babu, netdev
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Currently the error return path when lfs fails to allocate is not free'ing
the memory allocated to buf. Fix this by adding the missing kfree.
Addresses-Coverity: ("Resource leak")
Fixes: f7884097141b ("octeontx2-af: Formatting debugfs entry rsrc_alloc.")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
index 8ec17ee72b5d..9bf8eaabf9ab 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
@@ -253,8 +253,10 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
return -ENOSPC;
lfs = kzalloc(lf_str_size, GFP_KERNEL);
- if (!lfs)
+ if (!lfs) {
+ kfree(buf);
return -ENOMEM;
+ }
off += scnprintf(&buf[off], buf_size - 1 - off, "%-*s", lf_str_size,
"pcifunc");
for (index = 0; index < BLK_COUNT; index++)
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] octeontx2-af: Fix memory leak of object buf
2021-03-23 12:32 [PATCH] octeontx2-af: Fix memory leak of object buf Colin King
@ 2021-03-24 7:07 ` Sunil Kovvuri
2021-03-24 19:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Sunil Kovvuri @ 2021-03-24 7:07 UTC (permalink / raw)
To: Colin King
Cc: Sunil Goutham, Linu Cherian, Geetha sowjanya, Jerin Jacob,
hariprasad, Subbaraya Sundeep, David S . Miller, Jakub Kicinski,
Rakesh Babu, Linux Netdev List, kernel-janitors, LKML
On Tue, Mar 23, 2021 at 6:07 PM Colin King <colin.king@canonical.com> wrote:
>
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the error return path when lfs fails to allocate is not free'ing
> the memory allocated to buf. Fix this by adding the missing kfree.
>
> Addresses-Coverity: ("Resource leak")
> Fixes: f7884097141b ("octeontx2-af: Formatting debugfs entry rsrc_alloc.")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
> index 8ec17ee72b5d..9bf8eaabf9ab 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
> @@ -253,8 +253,10 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
> return -ENOSPC;
>
> lfs = kzalloc(lf_str_size, GFP_KERNEL);
> - if (!lfs)
> + if (!lfs) {
> + kfree(buf);
> return -ENOMEM;
> + }
> off += scnprintf(&buf[off], buf_size - 1 - off, "%-*s", lf_str_size,
> "pcifunc");
> for (index = 0; index < BLK_COUNT; index++)
> --
> 2.30.2
>
Thanks for the fix,
Acked-by: Sunil Goutham <sgoutham@marvell.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] octeontx2-af: Fix memory leak of object buf
2021-03-23 12:32 [PATCH] octeontx2-af: Fix memory leak of object buf Colin King
2021-03-24 7:07 ` Sunil Kovvuri
@ 2021-03-24 19:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-03-24 19:40 UTC (permalink / raw)
To: Colin King
Cc: sgoutham, lcherian, gakula, jerinj, hkelam, sbhatta, davem, kuba,
rsaladi2, netdev, kernel-janitors, linux-kernel
Hello:
This patch was applied to netdev/net.git (refs/heads/master):
On Tue, 23 Mar 2021 12:32:45 +0000 you wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the error return path when lfs fails to allocate is not free'ing
> the memory allocated to buf. Fix this by adding the missing kfree.
>
> Addresses-Coverity: ("Resource leak")
> Fixes: f7884097141b ("octeontx2-af: Formatting debugfs entry rsrc_alloc.")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>
> [...]
Here is the summary with links:
- octeontx2-af: Fix memory leak of object buf
https://git.kernel.org/netdev/net/c/9e0a537d06fc
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-24 19:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-23 12:32 [PATCH] octeontx2-af: Fix memory leak of object buf Colin King
2021-03-24 7:07 ` Sunil Kovvuri
2021-03-24 19:40 ` patchwork-bot+netdevbpf
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).