lkml.org 
[lkml]   [2021]   [Apr]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] PCI: Check value of resource alignment before using __ffs
On 21/04/22 09:43AM, Leon Romanovsky wrote:
> On Thu, Apr 22, 2021 at 12:17:47AM +0530, Amey Narkhede wrote:
> > Return value of __ffs is undefined if no set bit exists in
> > its argument. This indicates that the associated BAR has
> > invalid alignment.
> >
> > Signed-off-by: Amey Narkhede <ameynarkhede03@gmail.com>
> > ---
> > drivers/pci/setup-bus.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
> > index 2ce636937c6e..44e8449418ae 100644
> > --- a/drivers/pci/setup-bus.c
> > +++ b/drivers/pci/setup-bus.c
> > @@ -1044,6 +1044,11 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
> > * resources.
> > */
> > align = pci_resource_alignment(dev, r);
> > + if (!align) {
> > + pci_warn(dev, "BAR %d: %pR has bogus alignment\n",
> > + i, r);
> > + continue;
> > + }
>
> I see that you copied it from pdev_sort_resources(), but it is
> incorrect change, see how negative order is handled and later
> ARRAY_SIZE() check.
>
> Thanks
>
Is it guaranteed that it will return value which will result
in negative value or >= ARRAY_SIZE? Comment on __ffs says value
is undefined for 0 that means it could be anything or am I missing
something?

Thanks,
Amey

\
 
 \ /
  Last update: 2021-04-22 11:44    [W:0.104 / U:0.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site