public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] pci: Fix device_find_first_child() return value handling
@ 2023-07-16 15:53 Marek Vasut
  2023-07-17  7:42 ` Michal Suchánek
  2023-08-15 14:42 ` Tom Rini
  0 siblings, 2 replies; 6+ messages in thread
From: Marek Vasut @ 2023-07-16 15:53 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Jonas Karlman, Pali Rohár, Bin Meng,
	Michal Suchanek, Simon Glass

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@kwiboo.se>
Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: "Pali Rohár" <pali@kernel.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Michal Suchanek <msuchanek@suse.de>
Cc: Simon Glass <sjg@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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-08-15 14:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-16 15:53 [PATCH] pci: Fix device_find_first_child() return value handling Marek Vasut
2023-07-17  7:42 ` Michal Suchánek
2023-07-17 17:03   ` Marek Vasut
2023-07-27  0:49     ` Simon Glass
2023-07-27  6:42       ` Michal Suchánek
2023-08-15 14:42 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox