Hi Felipe, On 28 August 2017 at 15:58, Felipe Balbi <felipe.balbi@xxxxxxxxxxxxxxx> wrote: > > Hi, > > Baolin Wang <baolin.wang@xxxxxxxxxx> writes: >> Hi Dan, >> >> On 25 August 2017 at 20:20, Dan Carpenter <dan.carpenter@xxxxxxxxxx> 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. > > I want to keep NULL phy valid. It's best to remove the NULL check from > calling sites. OK. To keep consistent for all USB phy interfaces. -- Baolin.wang Best Regards -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html