kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: devices: mchp48l640: Fix memory leak on cmd
@ 2021-07-12 14:52 Colin King
  2021-07-15 22:50 ` Miquel Raynal
  2021-07-19  3:45 ` Heiko Schocher
  0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2021-07-12 14:52 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Heiko Schocher, linux-mtd
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The allocation for cmd is not being kfree'd on the return leading to
a memory leak. Fix this by kfree'ing it.

Addresses-Coverity: ("Resource leak")
Fixes: 88d125026753 ("mtd: devices: add support for microchip 48l640 EERAM")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/mtd/devices/mchp48l640.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/devices/mchp48l640.c b/drivers/mtd/devices/mchp48l640.c
index efc2003bd13a..c0b1a7bb7d13 100644
--- a/drivers/mtd/devices/mchp48l640.c
+++ b/drivers/mtd/devices/mchp48l640.c
@@ -255,6 +255,7 @@ static int mchp48l640_read_page(struct mtd_info *mtd, loff_t from, size_t len,
 	if (!ret)
 		*retlen += len;
 
+	kfree(cmd);
 	return ret;
 
 fail:
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mtd: devices: mchp48l640: Fix memory leak on cmd
  2021-07-12 14:52 [PATCH] mtd: devices: mchp48l640: Fix memory leak on cmd Colin King
@ 2021-07-15 22:50 ` Miquel Raynal
  2021-07-19  3:45 ` Heiko Schocher
  1 sibling, 0 replies; 3+ messages in thread
From: Miquel Raynal @ 2021-07-15 22:50 UTC (permalink / raw)
  To: Colin King, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Heiko Schocher, linux-mtd
  Cc: kernel-janitors, linux-kernel

On Mon, 2021-07-12 at 14:52:14 UTC, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The allocation for cmd is not being kfree'd on the return leading to
> a memory leak. Fix this by kfree'ing it.
> 
> Addresses-Coverity: ("Resource leak")
> Fixes: 88d125026753 ("mtd: devices: add support for microchip 48l640 EERAM")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/fixes, thanks.

Miquel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mtd: devices: mchp48l640: Fix memory leak on cmd
  2021-07-12 14:52 [PATCH] mtd: devices: mchp48l640: Fix memory leak on cmd Colin King
  2021-07-15 22:50 ` Miquel Raynal
@ 2021-07-19  3:45 ` Heiko Schocher
  1 sibling, 0 replies; 3+ messages in thread
From: Heiko Schocher @ 2021-07-19  3:45 UTC (permalink / raw)
  To: Colin King, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, linux-mtd
  Cc: kernel-janitors, linux-kernel

Hello Colin,

On 12.07.21 16:52, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The allocation for cmd is not being kfree'd on the return leading to
> a memory leak. Fix this by kfree'ing it.
> 
> Addresses-Coverity: ("Resource leak")
> Fixes: 88d125026753 ("mtd: devices: add support for microchip 48l640 EERAM")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/mtd/devices/mchp48l640.c | 1 +
>  1 file changed, 1 insertion(+)

Good catch, thanks!

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs@denx.de

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-19  3:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-12 14:52 [PATCH] mtd: devices: mchp48l640: Fix memory leak on cmd Colin King
2021-07-15 22:50 ` Miquel Raynal
2021-07-19  3:45 ` Heiko Schocher

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).