Skip to contentSkip to conversation

usb: dwc2: fix potential double free

PATCH In review Pan Bian 2 participants 2 messages Nov 6, 2019 – Nov 14, 2019

Subsystems (2)
lore
Share & tools
lore

Pan Bian

author
#0 lore raw

PATCH 1/1 usb: dwc2: fix potential double free

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")
---
 drivers/usb/dwc2/hcd.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/dwc2/hcd.c +1 -0
index 81afe553aa66..3b943352b296 100644
@@ -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
Signature · 1 line
2.7.4
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · 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")
Quoted 17 lines
---
  drivers/usb/dwc2/hcd.c | 1 +
  1 file changed, 1 insertion(+)
drivers/usb/dwc2/hcd.c +1 -0
index 81afe553aa66..3b943352b296 100644
@@ -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