[PATCH 13/20] alpha/PCI: Clean up __pci_mmap_fits()

Krzysztof Wilczyński kwilczynski at kernel.org
Fri Apr 10 21:21:32 AEST 2026


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?

Thank you!

	Krzysztof


More information about the Linuxppc-dev mailing list