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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220124173344.874885-2-sean.anderson@seco.com>
Date:   Mon, 24 Jan 2022 12:33:44 -0500
From:   Sean Anderson <sean.anderson@...o.com>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-usb@...r.kernel.org
Cc:     linux-kernel@...r.kernel.org,
        Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
        Sean Anderson <sean.anderson@...o.com>
Subject: [PATCH v2 2/2] usb: ulpi: Call of_node_put correctly

of_node_put should always be called on device nodes gotten from
of_get_*. Additionally, it should only be called after there are no
remaining users. To address the first issue, call of_node_put if later
steps in ulpi_register fail. To address the latter, call of_node_put
only after calling device_unregister.

Signed-off-by: Sean Anderson <sean.anderson@...o.com>
---

Changes in v2:
- New

 drivers/usb/common/ulpi.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c
index 87deb514eb78..c6ba72544f2b 100644
--- a/drivers/usb/common/ulpi.c
+++ b/drivers/usb/common/ulpi.c
@@ -301,11 +301,11 @@ static int ulpi_register(struct device *dev, struct ulpi *ulpi)
 
 	ret = ulpi_read_id(ulpi);
 	if (ret)
-		return ret;
+		goto err;
 
 	ret = device_register(&ulpi->dev);
 	if (ret)
-		return ret;
+		goto err;
 
 	root = debugfs_create_dir(dev_name(dev), ULPI_ROOT);
 	debugfs_create_file("regs", 0444, root, ulpi, &ulpi_regs_ops);
@@ -314,6 +314,10 @@ static int ulpi_register(struct device *dev, struct ulpi *ulpi)
 		ulpi->id.vendor, ulpi->id.product);
 
 	return 0;
+
+err:
+	of_node_put(ulpi->dev.of_node);
+	return ret;
 }
 
 /**
@@ -357,8 +361,8 @@ void ulpi_unregister_interface(struct ulpi *ulpi)
 {
 	debugfs_remove_recursive(debugfs_lookup(dev_name(&ulpi->dev),
 						ULPI_ROOT));
-	of_node_put(ulpi->dev.of_node);
 	device_unregister(&ulpi->dev);
+	of_node_put(ulpi->dev.of_node);
 }
 EXPORT_SYMBOL_GPL(ulpi_unregister_interface);
 
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ