diff options
author | Baolin Wang <baolin.wang@linaro.org> | 2017-08-28 07:02:41 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-08-31 12:08:47 -0400 |
commit | eb3c74de28b24f5a36d12d6c84f1fceb25d12c4f (patch) | |
tree | eb30f865259f233e31169b04d5456afd9ebf5c8a /include/linux/usb/phy.h | |
parent | 06e74935c77e8605d7d825cd3762cad2c70578ed (diff) |
usb: phy: Avoid unchecked dereference warning
Move the USB phy NULL checking before issuing usb_phy_set_charger_current()
to avoid unchecked dereference warning.
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/usb/phy.h')
-rw-r--r-- | include/linux/usb/phy.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h index de881b171ba9..8c6914873a16 100644 --- a/include/linux/usb/phy.h +++ b/include/linux/usb/phy.h | |||
@@ -322,9 +322,12 @@ static inline void usb_phy_set_charger_state(struct usb_phy *usb_phy, | |||
322 | static inline int | 322 | static inline int |
323 | usb_phy_set_power(struct usb_phy *x, unsigned mA) | 323 | usb_phy_set_power(struct usb_phy *x, unsigned mA) |
324 | { | 324 | { |
325 | if (!x) | ||
326 | return 0; | ||
327 | |||
325 | usb_phy_set_charger_current(x, mA); | 328 | usb_phy_set_charger_current(x, mA); |
326 | 329 | ||
327 | if (x && x->set_power) | 330 | if (x->set_power) |
328 | return x->set_power(x, mA); | 331 | return x->set_power(x, mA); |
329 | return 0; | 332 | return 0; |
330 | } | 333 | } |