[PATCH 13/20] alpha/PCI: Clean up __pci_mmap_fits()
Ilpo Järvinen
ilpo.jarvinen at linux.intel.com
Fri Apr 10 21:32:43 AEST 2026
On Fri, 10 Apr 2026, Krzysztof Wilczyński wrote:
> Hello,
>
> > > Currently, __pci_mmap_fits() computes the BAR size using
> > > pci_resource_len() - 1, which wraps to a large value when the
> > > BAR length is zero, causing the bounds check to incorrectly
> > > succeed.
> > >
> > > Thus, add an early return for empty resources.
> > >
> > > Also, remove the WARN() that fires when userspace attempts to
> > > mmap beyond the BAR bounds. The check still returns 0 to reject
> > > the mapping, but the warning is excessive for normal operation.
> > >
> > > A similar warning was removed from the PCI core in the commit
> > > 3b519e4ea618 ("PCI: fix size checks for mmap() on /proc/bus/pci files").
> >
> > This looks like entirely separate two changes to me which just happen
> > within the same context.
>
> True. I could split this into two separate patches. However, the early
> return is so trivial, that I decided to keep it here, in lieu of that the
> linked patch did, too.
>
> Thoughts?
It's not just adding the early return that would go to the first patch but
you also need to rearrange the len for that. Effectively, the change is
split in half, each becoming cleaner and more focused (both diff and the
changelog text).
As is I'm left on the borderline, while I can see it's "correct" after
splitting those changes inside my head, I also know it could have been
done better. I'd easily given rev-by for both if they'd have been done
individually, saved the time writing these emails about it, and
effectively "forgotten" the patches (including upcoming versions of the
series).
--
i.
More information about the Linuxppc-dev
mailing list