From: Amey Narkhede <ameynarkhede03@gmail.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PCI: Check value of resource alignment before using __ffs
Date: Thu, 22 Apr 2021 15:13:23 +0530 [thread overview]
Message-ID: <20210422094323.i4foiagx3hmzxpj4@archlinux> (raw)
In-Reply-To: <YIEa/5E45SzKzvuf@unreal>
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
next prev parent reply other threads:[~2021-04-22 9:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-21 18:47 [PATCH] PCI: Check value of resource alignment before using __ffs Amey Narkhede
2021-04-22 6:43 ` Leon Romanovsky
2021-04-22 9:43 ` Amey Narkhede [this message]
2021-04-22 10:41 ` Leon Romanovsky
2021-04-22 10:47 ` Amey Narkhede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210422094323.i4foiagx3hmzxpj4@archlinux \
--to=ameynarkhede03@gmail.com \
--cc=bhelgaas@google.com \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).