[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251119224140.8616-26-david.laight.linux@gmail.com>
Date: Wed, 19 Nov 2025 22:41:21 +0000
From: david.laight.linux@...il.com
To: linux-kernel@...r.kernel.org,
linux-pci@...r.kernel.org
Cc: Bjorn Helgaas <bhelgaas@...gle.com>,
David Laight <david.laight.linux@...il.com>
Subject: [PATCH 25/44] drivers/pci: use min() instead of min_t()
From: David Laight <david.laight.linux@...il.com>
min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'.
Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long'
and so cannot discard significant bits.
In this case although pci_hotplug_bus_size is 'long' it is constrained
to be <= 255.
Detected by an extra check added to min_t().
Signed-off-by: David Laight <david.laight.linux@...il.com>
---
drivers/pci/probe.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 0ce98e18b5a8..0f0d1b44d8c2 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -3163,8 +3163,7 @@ static unsigned int pci_scan_child_bus_extend(struct pci_bus *bus,
* bus number if there is room.
*/
if (bus->self && bus->self->is_hotplug_bridge) {
- used_buses = max_t(unsigned int, available_buses,
- pci_hotplug_bus_size - 1);
+ used_buses = max(available_buses, pci_hotplug_bus_size - 1);
if (max - start < used_buses) {
max = start + used_buses;
--
2.39.5
Powered by blists - more mailing lists