Hi Dan, On 25 August 2017 at 20:20, Dan Carpenter <dan.carpen...@oracle.com> wrote: > Hello Baolin Wang, > > This is a semi-automatic email about new static checker warnings. > > The patch a9081a008f84: "usb: phy: Add USB charger support" from Aug > 15, 2017, leads to the following Smatch complaint: > > include/linux/usb/phy.h:327 usb_phy_set_power() > warn: variable dereferenced before check 'x' (see line 325) > > include/linux/usb/phy.h > 322 static inline int > 323 usb_phy_set_power(struct usb_phy *x, unsigned mA) > 324 { > 325 usb_phy_set_charger_current(x, mA); > ^ > The patch adds an unchecked dereference. > > 326 > 327 if (x && x->set_power) > ^ > The existing code checks for NULL. But so far as I know non of the > existing caller pass a NULL usb_phy and it doesn't really make sense > to me to do that. Perhaps just remove the NULL check?
I agree. I also saw most drivers will check for NULL before issuing usb_phy_set_power(). I will send one patch to fix this issue. Thanks. -- Baolin.wang Best Regards -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html