[PATCH] pci: Fix device_find_first_child() return value handling

Marek Vasut marex at denx.de
Sun Jul 16 17:53:24 CEST 2023


This function only ever returns 0, but may not assign the second
parameter. Same thing for device_find_next_child(). Do not assign
ret to stop proliferation of this misuse.

Reported-by: Jonas Karlman <jonas at kwiboo.se>
Signed-off-by: Marek Vasut <marex at denx.de>
---
Cc: "Pali Rohár" <pali at kernel.org>
Cc: Bin Meng <bmeng.cn at gmail.com>
Cc: Marek Vasut <marex at denx.de>
Cc: Michal Suchanek <msuchanek at suse.de>
Cc: Simon Glass <sjg at chromium.org>
---
 drivers/pci/pci-uclass.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index 8d27e40338c..6421eda7721 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -545,9 +545,9 @@ int pci_auto_config_devices(struct udevice *bus)
 	sub_bus = dev_seq(bus);
 	debug("%s: start\n", __func__);
 	pciauto_config_init(hose);
-	for (ret = device_find_first_child(bus, &dev);
-	     !ret && dev;
-	     ret = device_find_next_child(&dev)) {
+	for (device_find_first_child(bus, &dev);
+	     dev;
+	     device_find_next_child(&dev)) {
 		unsigned int max_bus;
 		int ret;
 
-- 
2.40.1



More information about the U-Boot mailing list