From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Cc: "Marek Vasut" <marex@denx.de>, "Jonas Karlman" <jonas@kwiboo.se>,
"Pali Rohár" <pali@kernel.org>, "Bin Meng" <bmeng.cn@gmail.com>,
"Michal Suchanek" <msuchanek@suse.de>,
"Simon Glass" <sjg@chromium.org>
Subject: [PATCH] pci: Fix device_find_first_child() return value handling
Date: Sun, 16 Jul 2023 17:53:24 +0200 [thread overview]
Message-ID: <20230716155324.11211-1-marex@denx.de> (raw)
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
next reply other threads:[~2023-07-16 15:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-16 15:53 Marek Vasut [this message]
2023-07-17 7:42 ` [PATCH] pci: Fix device_find_first_child() return value handling 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230716155324.11211-1-marex@denx.de \
--to=marex@denx.de \
--cc=bmeng.cn@gmail.com \
--cc=jonas@kwiboo.se \
--cc=msuchanek@suse.de \
--cc=pali@kernel.org \
--cc=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox