summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikhil Badola <nikhil.badola@freescale.com>2019-10-21 12:21:51 +0200
committerFelipe Balbi <balbi@kernel.org>2019-10-27 07:58:44 +0100
commitbc1e3a2dd0c9954fd956ac43ca2876bbea018c01 (patch)
tree4a3e85f5b50be56fe905226af3b559812cd3832c
parentusb: dwc3: select CONFIG_REGMAP_MMIO (diff)
downloadlinux-bc1e3a2dd0c9954fd956ac43ca2876bbea018c01.tar.xz
linux-bc1e3a2dd0c9954fd956ac43ca2876bbea018c01.zip
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>
-rw-r--r--drivers/usb/gadget/udc/fsl_udc_core.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c b/drivers/usb/gadget/udc/fsl_udc_core.c
index 20141c3096f6..9a05863b2876 100644
--- a/drivers/usb/gadget/udc/fsl_udc_core.c
+++ b/drivers/usb/gadget/udc/fsl_udc_core.c
@@ -2576,7 +2576,7 @@ static int fsl_udc_remove(struct platform_device *pdev)
dma_pool_destroy(udc_controller->td_pool);
free_irq(udc_controller->irq, udc_controller);
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));
/* free udc --wait for the release() finished */