Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1721521

[PATCH] usb: phy: Avoid unchecked dereference warning

From Baolin Wang <baolin.wang@linaro.org>
Newsgroups linux.kernel
Subject [PATCH] usb: phy: Avoid unchecked dereference warning
Date 2017-08-28 13:10 +0200
Message-ID <ujq5B-4T5-29@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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>
---
 include/linux/usb/phy.h |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index de881b1..8c69148 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,
 static inline int
 usb_phy_set_power(struct usb_phy *x, unsigned mA)
 {
+	if (!x)
+		return 0;
+
 	usb_phy_set_charger_current(x, mA);
 
-	if (x && x->set_power)
+	if (x->set_power)
 		return x->set_power(x, mA);
 	return 0;
 }
-- 
1.7.9.5

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH] usb: phy: Avoid unchecked dereference warning Baolin Wang <baolin.wang@linaro.org> - 2017-08-28 13:10 +0200

csiph-web