Re: [PATCH v2 1/3] PCI: Relaxed tail alignment should never increase min_align

From: Ilpo Järvinen
Date: Thu Aug 21 2025 - 12:49:28 EST


On Thu, 21 Aug 2025, Markus Elfring wrote:

>
> > Ensure min_align is not increased by the relaxed tail alignment.
>
>
>
>
> +++ b/drivers/pci/setup-bus.c
>
> @@ -1261,8 +1263,9 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
> if (bus->self && size1 &&
> !pbus_upstream_space_available(bus, mask | IORESOURCE_PREFETCH, type,
> size1, add_align)) {
> - min_align = 1ULL << (max_order + __ffs(SZ_1M));
> - min_align = max(min_align, win_align);
> + relaxed_align = 1ULL << (max_order + __ffs(SZ_1M));
> + relaxed_align = max(min_align, win_align);
>
>
> I wonder why a variable content would be overwritten here
> without using the previous value.
> https://cwe.mitre.org/data/definitions/563.html

Hi Markus,

This looks a very good catch. I think it too should have been:

relaxed_align = max(relaxed_align, win_align);

...like in the other case.

--
i.