usb: fsl: Check memory resource before releasing it

Check memory resource existence before releasing it to avoid NULL
pointer dereference

Signed-off-by: Nikhil Badola <nikhil.badola@freescale.com>
Reviewed-by: Ran Wang <ran.wang_1@nxp.com>
Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
This commit is contained in:
Nikhil Badola 2019-10-21 18:21:51 +08:00 committed by Felipe Balbi
parent a51bab592f
commit bc1e3a2dd0
1 changed files with 1 additions and 1 deletions

View File

@ -2576,7 +2576,7 @@ static int fsl_udc_remove(struct platform_device *pdev)
dma_pool_destroy(udc_controller->td_pool); dma_pool_destroy(udc_controller->td_pool);
free_irq(udc_controller->irq, udc_controller); free_irq(udc_controller->irq, udc_controller);
iounmap(dr_regs); iounmap(dr_regs);
if (pdata->operating_mode == FSL_USB2_DR_DEVICE) if (res && (pdata->operating_mode == FSL_USB2_DR_DEVICE))
release_mem_region(res->start, resource_size(res)); release_mem_region(res->start, resource_size(res));
/* free udc --wait for the release() finished */ /* free udc --wait for the release() finished */