linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] memstick: jmb38x_ms: use appropriate free function in jmb38x_ms_alloc_host()
@ 2021-10-11 12:39 Dan Carpenter
  2021-10-12  8:27 ` Ulf Hansson
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2021-10-11 12:39 UTC (permalink / raw)
  To: Maxim Levitsky, Ulf Hansson, Alex Dubov
  Cc: Len Baker, Tom Rix, linux-mmc, kernel-janitors

The "msh" pointer is device managed, meaning that memstick_alloc_host()
calls device_initialize() on it.  That means that it can't be free
using kfree() but must instead be freed with memstick_free_host().
Otherwise it leads to a tiny memory leak of device resources.

Fixes: 60fdd931d577 ("memstick: add support for JMicron jmb38x MemoryStick host controller")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/memstick/host/jmb38x_ms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/memstick/host/jmb38x_ms.c b/drivers/memstick/host/jmb38x_ms.c
index a7a0f0caea15..21cb2a786058 100644
--- a/drivers/memstick/host/jmb38x_ms.c
+++ b/drivers/memstick/host/jmb38x_ms.c
@@ -882,7 +882,7 @@ static struct memstick_host *jmb38x_ms_alloc_host(struct jmb38x_ms *jm, int cnt)
 
 	iounmap(host->addr);
 err_out_free:
-	kfree(msh);
+	memstick_free_host(msh);
 	return NULL;
 }
 
-- 
2.20.1


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

* Re: [PATCH] memstick: jmb38x_ms: use appropriate free function in jmb38x_ms_alloc_host()
  2021-10-11 12:39 [PATCH] memstick: jmb38x_ms: use appropriate free function in jmb38x_ms_alloc_host() Dan Carpenter
@ 2021-10-12  8:27 ` Ulf Hansson
  0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2021-10-12  8:27 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Maxim Levitsky, Alex Dubov, Len Baker, Tom Rix, linux-mmc,
	kernel-janitors

On Mon, 11 Oct 2021 at 14:39, Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> The "msh" pointer is device managed, meaning that memstick_alloc_host()
> calls device_initialize() on it.  That means that it can't be free
> using kfree() but must instead be freed with memstick_free_host().
> Otherwise it leads to a tiny memory leak of device resources.
>
> Fixes: 60fdd931d577 ("memstick: add support for JMicron jmb38x MemoryStick host controller")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied for next, thanks!

Kind regards
Uffe


> ---
>  drivers/memstick/host/jmb38x_ms.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/memstick/host/jmb38x_ms.c b/drivers/memstick/host/jmb38x_ms.c
> index a7a0f0caea15..21cb2a786058 100644
> --- a/drivers/memstick/host/jmb38x_ms.c
> +++ b/drivers/memstick/host/jmb38x_ms.c
> @@ -882,7 +882,7 @@ static struct memstick_host *jmb38x_ms_alloc_host(struct jmb38x_ms *jm, int cnt)
>
>         iounmap(host->addr);
>  err_out_free:
> -       kfree(msh);
> +       memstick_free_host(msh);
>         return NULL;
>  }
>
> --
> 2.20.1
>

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

end of thread, other threads:[~2021-10-12  8:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-11 12:39 [PATCH] memstick: jmb38x_ms: use appropriate free function in jmb38x_ms_alloc_host() Dan Carpenter
2021-10-12  8:27 ` Ulf Hansson

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