Skip to contentSkip to conversation

usb: dwc3: drd: Defer probe if extcon device is not found

bug report Dan Carpenter 2 participants 3 messages Oct 14, 2022 – Oct 18, 2022 USB

lore
Share & tools
lore
#0 lore raw

Hello Andy Shevchenko,

The patch 98bba546e82d: "usb: dwc3: drd: Defer probe if extcon device is not found" from Feb 18, 2019, leads to the following Smatch static checker warning:

	drivers/usb/dwc3/drd.c:460 dwc3_get_extcon()
	warn: 'edev' is an error pointer or valid

drivers/usb/dwc3/drd.c

    442 static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc)
    443 {
    444         struct device *dev = dwc->dev;
    445         struct device_node *np_phy;
    446         struct extcon_dev *edev = NULL;
    447         const char *name;
    448 
    449         if (device_property_read_bool(dev, "extcon"))
    450                 return extcon_get_edev_by_phandle(dev, 0);
    451 
    452         /*
    453          * Device tree platforms should get extcon via phandle.
    454          * On ACPI platforms, we get the name from a device property.
    455          * This device property is for kernel internal use only and
    456          * is expected to be set by the glue code.
    457          */
    458         if (device_property_read_string(dev, "linux,extcon-name", &name) == 0) {
    459                 edev = extcon_get_extcon_dev(name);
--> 460                 if (!edev)
    461                         return ERR_PTR(-EPROBE_DEFER);

This extcon_get_extcon_dev() returns NULL when CONFIG_EXTCON is disabled otherwise it returns error pointers on error. -EPROBE_DEFER does not make sense for a .config issue.

    462 
    463                 return edev;
    464         }
    465 
    466         /*
    467          * Try to get an extcon device from the USB PHY controller's "port"
    468          * node. Check if it has the "port" node first, to avoid printing the
    469          * error message from underlying code, as it's a valid case: extcon
    470          * device (and "port" node) may be missing in case of "usb-role-switch"
    471          * or OTG mode.
    472          */
    473         np_phy = of_parse_phandle(dev->of_node, "phys", 0);
    474         if (of_graph_is_present(np_phy)) {
    475                 struct device_node *np_conn;
    476 
    477                 np_conn = of_graph_get_remote_node(np_phy, -1, -1);
    478                 if (np_conn)
    479                         edev = extcon_find_edev_by_node(np_conn);
    480                 of_node_put(np_conn);
    481         }
    482         of_node_put(np_phy);
    483 
    484         return edev;
    485 }

regards,
dan carpenter

#1 lore raw
Quoted 8 lines · Dan Carpenter

Hello Andy Shevchenko,

The patch 98bba546e82d: "usb: dwc3: drd: Defer probe if extcon device is not found" from Feb 18, 2019, leads to the following Smatch static checker warning:

	drivers/usb/dwc3/drd.c:460 dwc3_get_extcon()
	warn: 'edev' is an error pointer or valid

The culprit is wrong, but the rest seems correct.
Thank you.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
In reply to Dan Carpenter
Quoted 8 lines · Dan Carpenter

Hello Andy Shevchenko,

The patch 98bba546e82d: "usb: dwc3: drd: Defer probe if extcon device is not found" from Feb 18, 2019, leads to the following Smatch static checker warning:

	drivers/usb/dwc3/drd.c:460 dwc3_get_extcon()
	warn: 'edev' is an error pointer or valid

Should be fixed (as a side effect) by https://lore.kernel.org/r/[email protected]

Signature · 2 lines
With Best Regards,
Andy Shevchenko