[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191021102153.16435-1-yinbo.zhu@nxp.com>
Date: Mon, 21 Oct 2019 18:21:51 +0800
From: Yinbo Zhu <yinbo.zhu@....com>
To: Li Yang <leoyang.li@....com>, Felipe Balbi <balbi@...nel.org>
Cc: yinbo.zhu@....com, xiaobo.xie@....com, jiafei.pan@....com,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-usb@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
linux-kernel@...r.kernel.org, Ran Wang <ran.wang_1@....com>,
Nikhil Badola <nikhil.badola@...escale.com>
Subject: [PATCH v1] usb: fsl: Check memory resource before releasing it
From: Nikhil Badola <nikhil.badola@...escale.com>
Check memory resource existence before releasing it to avoid NULL
pointer dereference
Signed-off-by: Nikhil Badola <nikhil.badola@...escale.com>
Reviewed-by: Ran Wang <ran.wang_1@....com>
Reviewed-by: Peter Chen <peter.chen@....com>
---
drivers/usb/gadget/udc/fsl_udc_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 */
--
2.17.1
Powered by blists - more mailing lists