Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 1/1] usb: dwc2: fix potential double free
@ 2019-11-06  1:54 Pan Bian
  2019-11-14  9:49 ` Minas Harutyunyan
  0 siblings, 1 reply; 2+ messages in thread
From: Pan Bian @ 2019-11-06  1:54 UTC (permalink / raw)
  To: Minas Harutyunyan, Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel, Pan Bian

The member hsotg->desc_gen_cache is assigned NULL after it is destroyed
to avoid being freed twice when the call to usb_add_hcd() fails.

Fixes: 3b5fcc9ac2f4 ("usb: dwc2: host: use kmem cache to allocate descriptors")

Signed-off-by: Pan Bian <bianpan2016@163.com>
---
 drivers/usb/dwc2/hcd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 81afe553aa66..3b943352b296 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -5183,6 +5183,7 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg)
 				"unable to create dwc2 hs isoc desc cache\n");
 
 			kmem_cache_destroy(hsotg->desc_gen_cache);
+			hsotg->desc_gen_cache = NULL;
 
 			/*
 			 * Disable descriptor dma mode since it will not be
-- 
2.7.4


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

* Re: [PATCH 1/1] usb: dwc2: fix potential double free
  2019-11-06  1:54 [PATCH 1/1] usb: dwc2: fix potential double free Pan Bian
@ 2019-11-14  9:49 ` Minas Harutyunyan
  0 siblings, 0 replies; 2+ messages in thread
From: Minas Harutyunyan @ 2019-11-14  9:49 UTC (permalink / raw)
  To: Pan Bian, Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel



On 11/6/2019 5:54 AM, Pan Bian wrote:
> The member hsotg->desc_gen_cache is assigned NULL after it is destroyed
> to avoid being freed twice when the call to usb_add_hcd() fails.
> 
> Fixes: 3b5fcc9ac2f4 ("usb: dwc2: host: use kmem cache to allocate descriptors")
> 
> Signed-off-by: Pan Bian <bianpan2016@163.com>

Acked-by: Minas Harutyunyan <hminas@synopsys.com>

> ---
>   drivers/usb/dwc2/hcd.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
> index 81afe553aa66..3b943352b296 100644
> --- a/drivers/usb/dwc2/hcd.c
> +++ b/drivers/usb/dwc2/hcd.c
> @@ -5183,6 +5183,7 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg)
>   				"unable to create dwc2 hs isoc desc cache\n");
>   
>   			kmem_cache_destroy(hsotg->desc_gen_cache);
> +			hsotg->desc_gen_cache = NULL;
>   
>   			/*
>   			 * Disable descriptor dma mode since it will not be
> 

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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-06  1:54 [PATCH 1/1] usb: dwc2: fix potential double free Pan Bian
2019-11-14  9:49 ` Minas Harutyunyan

Linux-USB Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-usb/0 linux-usb/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-usb linux-usb/ https://lore.kernel.org/linux-usb \
		linux-usb@vger.kernel.org
	public-inbox-index linux-usb

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-usb


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git