lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Mon, 28 Aug 2017 19:02:41 +0800
From:   Baolin Wang <baolin.wang@...aro.org>
To:     balbi@...nel.org, gregkh@...uxfoundation.org
Cc:     linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
        dan.carpenter@...cle.com, broonie@...nel.org,
        baolin.wang@...aro.org
Subject: [PATCH] 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@...aro.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ