Skip to contentSkip to conversation

usb: chipidea: fix static checker warning for NULL pointer

PATCH New Greg Kroah-Hartman 1 participant 1 message Jan 17, 2019 USB

lore
Share & tools
lore

Greg Kroah-Hartman

author maintainer
#0 lore raw

PATCH 1/1 usb: chipidea: fix static checker warning for NULL pointer

Quoted 1 line · Peter Chen

During the static checker, "data->usbmisc_data" may be NULL.

I can not quite parse this sentance. Do you mean that a static checker found this issue?

Quoted 13 lines

Fix it by adding this pointer judgement before using.

---
 drivers/usb/chipidea/ci_hdrc_imx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/chipidea/ci_hdrc_imx.c +0 -0
index e81de9ca8729..9b45aa422e69 100644

drivers/usb/chipidea/ci_hdrc_imx.c static int ci_hdrc_imx_probe(struct platform_device *pdev) · line 320

Quoted 6 lines
drivers/usb/chipidea/ci_hdrc_imx.c +2 -1
@@ -316,7 +316,8 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
 	if (IS_ERR(data->usbmisc_data))
 		return PTR_ERR(data->usbmisc_data);
 
-	if (of_usb_get_phy_mode(dev->of_node) == USBPHY_INTERFACE_MODE_HSIC) {
+	if ((of_usb_get_phy_mode(dev->of_node) == USBPHY_INTERFACE_MODE_HSIC)
+		&& data->usbmisc_data) {

Are you sure that is correct? If usbmisc_data is NULL, then you just took out a bunch of checking and lookups. Don't you normally need to do this even if that pointer is NULL?

Will the rest of the function still work properly if that is the case?

thanks,

greg k-h