* RE: [PATCH] crypto: caam - fix memleak in caam_jr module
@ 2014-07-03 7:52 Vakul Garg
2014-07-03 12:07 ` [PATCH v2] " Cristian Stoica
0 siblings, 1 reply; 4+ messages in thread
From: Vakul Garg @ 2014-07-03 7:52 UTC (permalink / raw)
To: cristian.stoica@freescale.com; +Cc: linux-crypto@vger.kernel.org
This patch fixes a memory leak that appears when caam_jr module is unloaded.
Cc: <stable@vger.kernel.org> # 3.13+
Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com>
---
drivers/crypto/caam/jr.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c
index 1d80bd3..f127f86 100644
--- a/drivers/crypto/caam/jr.c
+++ b/drivers/crypto/caam/jr.c
@@ -117,6 +117,7 @@ static int caam_jr_remove(struct platform_device *pdev)
if (ret)
dev_err(jrdev, "Failed to shut down job ring\n");
irq_dispose_mapping(jrpriv->irq);
+ kfree(jrpriv);
Can you replace kmalloc for jrpriv with devm_kzalloc() instead?
This will fix leaks for jrpriv in other places as well and make code compact.
return ret;
}
--
1.8.3.1
--
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2] crypto: caam - fix memleak in caam_jr module
2014-07-03 7:52 [PATCH] crypto: caam - fix memleak in caam_jr module Vakul Garg
@ 2014-07-03 12:07 ` Cristian Stoica
2014-07-03 22:54 ` Kim Phillips
0 siblings, 1 reply; 4+ messages in thread
From: Cristian Stoica @ 2014-07-03 12:07 UTC (permalink / raw)
To: Herbert Xu; +Cc: linux-crypto, David S. Miller
This patch fixes a memory leak that appears when caam_jr module is unloaded.
Cc: <stable@vger.kernel.org> # 3.13+
Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com>
---
drivers/crypto/caam/jr.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c
index 1d80bd3..e0b91fc 100644
--- a/drivers/crypto/caam/jr.c
+++ b/drivers/crypto/caam/jr.c
@@ -453,7 +453,7 @@ static int caam_jr_probe(struct platform_device *pdev)
int error;
jrdev = &pdev->dev;
- jrpriv = kmalloc(sizeof(struct caam_drv_private_jr),
+ jrpriv = devm_kzalloc(jrdev, sizeof(struct caam_drv_private_jr),
GFP_KERNEL);
if (!jrpriv)
return -ENOMEM;
@@ -487,10 +487,8 @@ static int caam_jr_probe(struct platform_device *pdev)
/* Now do the platform independent part */
error = caam_jr_init(jrdev); /* now turn on hardware */
- if (error) {
- kfree(jrpriv);
+ if (error)
return error;
- }
jrpriv->dev = jrdev;
spin_lock(&driver_data.jr_alloc_lock);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] crypto: caam - fix memleak in caam_jr module
2014-07-03 12:07 ` [PATCH v2] " Cristian Stoica
@ 2014-07-03 22:54 ` Kim Phillips
2014-07-09 20:31 ` Marek Vasut
0 siblings, 1 reply; 4+ messages in thread
From: Kim Phillips @ 2014-07-03 22:54 UTC (permalink / raw)
To: Cristian Stoica; +Cc: Herbert Xu, linux-crypto, David S. Miller
On Thu, 3 Jul 2014 15:07:50 +0300
Cristian Stoica <cristian.stoica@freescale.com> wrote:
> This patch fixes a memory leak that appears when caam_jr module is unloaded.
>
> Cc: <stable@vger.kernel.org> # 3.13+
> Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com>
> ---
> drivers/crypto/caam/jr.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c
> index 1d80bd3..e0b91fc 100644
> --- a/drivers/crypto/caam/jr.c
> +++ b/drivers/crypto/caam/jr.c
> @@ -453,7 +453,7 @@ static int caam_jr_probe(struct platform_device *pdev)
> int error;
>
> jrdev = &pdev->dev;
> - jrpriv = kmalloc(sizeof(struct caam_drv_private_jr),
> + jrpriv = devm_kzalloc(jrdev, sizeof(struct caam_drv_private_jr),
> GFP_KERNEL);
alignment. Also, why are we replacing a _m_alloc with a _z_alloc?
Please start using get_maintainer.pl.
Thanks,
Kim
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] crypto: caam - fix memleak in caam_jr module
2014-07-03 22:54 ` Kim Phillips
@ 2014-07-09 20:31 ` Marek Vasut
0 siblings, 0 replies; 4+ messages in thread
From: Marek Vasut @ 2014-07-09 20:31 UTC (permalink / raw)
To: Kim Phillips; +Cc: Cristian Stoica, Herbert Xu, linux-crypto, David S. Miller
On Friday, July 04, 2014 at 12:54:06 AM, Kim Phillips wrote:
> On Thu, 3 Jul 2014 15:07:50 +0300
>
> Cristian Stoica <cristian.stoica@freescale.com> wrote:
> > This patch fixes a memory leak that appears when caam_jr module is
> > unloaded.
> >
> > Cc: <stable@vger.kernel.org> # 3.13+
> > Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com>
> > ---
> >
> > drivers/crypto/caam/jr.c | 6 ++----
> > 1 file changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c
> > index 1d80bd3..e0b91fc 100644
> > --- a/drivers/crypto/caam/jr.c
> > +++ b/drivers/crypto/caam/jr.c
> > @@ -453,7 +453,7 @@ static int caam_jr_probe(struct platform_device
> > *pdev)
> >
> > int error;
> >
> > jrdev = &pdev->dev;
> >
> > - jrpriv = kmalloc(sizeof(struct caam_drv_private_jr),
> > + jrpriv = devm_kzalloc(jrdev, sizeof(struct caam_drv_private_jr),
> >
> > GFP_KERNEL);
>
> alignment. Also, why are we replacing a _m_alloc with a _z_alloc?
I am fine with replacing kmalloc with kzalloc in this context.
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-07-09 21:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-03 7:52 [PATCH] crypto: caam - fix memleak in caam_jr module Vakul Garg
2014-07-03 12:07 ` [PATCH v2] " Cristian Stoica
2014-07-03 22:54 ` Kim Phillips
2014-07-09 20:31 ` Marek Vasut
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).