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>] [thread-next>] [day] [month] [year] [list]
Date:   Sun, 12 Dec 2021 06:50:14 +0000
From:   Miaoqian Lin <linmq006@...il.com>
To:     unlisted-recipients:; (no To-header on input)
Cc:     linmq006@...il.com, JC Kuo <jckuo@...dia.com>,
        Kishon Vijay Abraham I <kishon@...com>,
        Vinod Koul <vkoul@...nel.org>,
        Thierry Reding <thierry.reding@...il.com>,
        Jonathan Hunter <jonathanh@...dia.com>,
        linux-phy@...ts.infradead.org, linux-tegra@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH] phy: tegra: xusb: Fix NULL vs IS_ERR_OR_NULL checking

The tegra_xusb_find_port_node() function may return error pointer when
kasprintf() return NULL. Using IS_ERR_OR_NULL to check the return value
of tegra_xusb_find_port_node() to catch this.

Signed-off-by: Miaoqian Lin <linmq006@...il.com>
---
 drivers/phy/tegra/xusb.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
index 963de5913e50..52c2f85c67c3 100644
--- a/drivers/phy/tegra/xusb.c
+++ b/drivers/phy/tegra/xusb.c
@@ -472,7 +472,7 @@ tegra_xusb_find_port(struct tegra_xusb_padctl *padctl, const char *type,
 	struct device_node *np;
 
 	np = tegra_xusb_find_port_node(padctl, type, index);
-	if (!np)
+	if (IS_ERR_OR_NULL(np))
 		return NULL;
 
 	list_for_each_entry(port, &padctl->ports, list) {
@@ -763,7 +763,7 @@ static int tegra_xusb_add_usb2_port(struct tegra_xusb_padctl *padctl,
 	 * marked as disabled there is no reason to register it.
 	 */
 	np = tegra_xusb_find_port_node(padctl, "usb2", index);
-	if (!np || !of_device_is_available(np))
+	if (IS_ERR_OR_NULL(np) || !of_device_is_available(np))
 		goto out;
 
 	usb2 = kzalloc(sizeof(*usb2), GFP_KERNEL);
@@ -829,7 +829,7 @@ static int tegra_xusb_add_ulpi_port(struct tegra_xusb_padctl *padctl,
 	int err = 0;
 
 	np = tegra_xusb_find_port_node(padctl, "ulpi", index);
-	if (!np || !of_device_is_available(np))
+	if (IS_ERR_OR_NULL(np) || !of_device_is_available(np))
 		goto out;
 
 	ulpi = kzalloc(sizeof(*ulpi), GFP_KERNEL);
@@ -884,7 +884,7 @@ static int tegra_xusb_add_hsic_port(struct tegra_xusb_padctl *padctl,
 	int err = 0;
 
 	np = tegra_xusb_find_port_node(padctl, "hsic", index);
-	if (!np || !of_device_is_available(np))
+	if (IS_ERR_OR_NULL(np) || !of_device_is_available(np))
 		goto out;
 
 	hsic = kzalloc(sizeof(*hsic), GFP_KERNEL);
@@ -970,7 +970,7 @@ static int tegra_xusb_add_usb3_port(struct tegra_xusb_padctl *padctl,
 	 * hence return 0 instead of an error to allow ports to be optional.
 	 */
 	np = tegra_xusb_find_port_node(padctl, "usb3", index);
-	if (!np || !of_device_is_available(np))
+	if (IS_ERR_OR_NULL(np) || !of_device_is_available(np))
 		goto out;
 
 	usb3 = kzalloc(sizeof(*usb3), GFP_KERNEL);
@@ -1035,7 +1035,7 @@ static int tegra_xusb_find_unused_usb3_port(struct tegra_xusb_padctl *padctl)
 
 	for (i = 0; i < padctl->soc->ports.usb3.count; i++) {
 		np = tegra_xusb_find_port_node(padctl, "usb3", i);
-		if (!np || !of_device_is_available(np))
+		if (IS_ERR_OR_NULL(np) || !of_device_is_available(np))
 			return i;
 	}
 
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ