* [PATCH] usb: dwc2: Use kmem_cache_free()
@ 2016-02-22 8:10 Amitoj Kaur Chawla
2016-02-24 3:59 ` John Youn
0 siblings, 1 reply; 2+ messages in thread
From: Amitoj Kaur Chawla @ 2016-02-22 8:10 UTC (permalink / raw)
To: johnyoun, gregkh, linux-usb, linux-kernel; +Cc: julia.lawall
Here, free memory is allocated using kmem_cache_zalloc. So, use
kmem_cache_free instead of kfree.
This is done using Coccinelle and semantic patch used
is as follows:
//<smpl>
@@
expression x,E,c;
@@
x =
\(kmem_cache_alloc\|kmem_cache_zalloc\|kmem_cache_alloc_node\)(c,...)
... when != x = E
when != &x
?-kfree(x)
+kmem_cache_free(c,x)
//</smpl>
Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
drivers/usb/dwc2/hcd_ddma.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/dwc2/hcd_ddma.c b/drivers/usb/dwc2/hcd_ddma.c
index 36606fc..d6ebd16 100644
--- a/drivers/usb/dwc2/hcd_ddma.c
+++ b/drivers/usb/dwc2/hcd_ddma.c
@@ -111,7 +111,7 @@ static int dwc2_desc_list_alloc(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh,
dma_unmap_single(hsotg->dev, qh->desc_list_dma,
qh->desc_list_sz,
DMA_FROM_DEVICE);
- kfree(qh->desc_list);
+ kmem_cache_free(desc_cache, qh->desc_list);
qh->desc_list = NULL;
return -ENOMEM;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] usb: dwc2: Use kmem_cache_free()
2016-02-22 8:10 [PATCH] usb: dwc2: Use kmem_cache_free() Amitoj Kaur Chawla
@ 2016-02-24 3:59 ` John Youn
0 siblings, 0 replies; 2+ messages in thread
From: John Youn @ 2016-02-24 3:59 UTC (permalink / raw)
To: Amitoj Kaur Chawla, John.Youn@synopsys.com,
gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org, Felipe Balbi
Cc: julia.lawall@lip6.fr
On 2/22/2016 12:11 AM, Amitoj Kaur Chawla wrote:
> Here, free memory is allocated using kmem_cache_zalloc. So, use
> kmem_cache_free instead of kfree.
>
> This is done using Coccinelle and semantic patch used
> is as follows:
>
> //<smpl>
> @@
> expression x,E,c;
> @@
> x =
> \(kmem_cache_alloc\|kmem_cache_zalloc\|kmem_cache_alloc_node\)(c,...)
> ... when != x = E
> when != &x
> ?-kfree(x)
> +kmem_cache_free(c,x)
> //</smpl>
>
> Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
> ---
> drivers/usb/dwc2/hcd_ddma.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/dwc2/hcd_ddma.c b/drivers/usb/dwc2/hcd_ddma.c
> index 36606fc..d6ebd16 100644
> --- a/drivers/usb/dwc2/hcd_ddma.c
> +++ b/drivers/usb/dwc2/hcd_ddma.c
> @@ -111,7 +111,7 @@ static int dwc2_desc_list_alloc(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh,
> dma_unmap_single(hsotg->dev, qh->desc_list_dma,
> qh->desc_list_sz,
> DMA_FROM_DEVICE);
> - kfree(qh->desc_list);
> + kmem_cache_free(desc_cache, qh->desc_list);
> qh->desc_list = NULL;
> return -ENOMEM;
> }
>
Acked-by: John Youn <johnyoun@synopsys.com>
John
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-02-24 4:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-22 8:10 [PATCH] usb: dwc2: Use kmem_cache_free() Amitoj Kaur Chawla
2016-02-24 3:59 ` John Youn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox