All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Guixin Liu <kanie@linux.alibaba.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] PCI: Check rom header and data structure addr before accessing
Date: Wed, 26 Nov 2025 19:42:10 +0200	[thread overview]
Message-ID: <aSc78vbl70YCWR56@smile.fi.intel.com> (raw)
In-Reply-To: <aSc7Qqn9r_HCbash@smile.fi.intel.com>

On Wed, Nov 26, 2025 at 07:39:18PM +0200, Andy Shevchenko wrote:
> On Wed, Nov 26, 2025 at 08:57:27PM +0800, Guixin Liu wrote:

...

> >  	image = rom;
> >  	do {
> >  		void __iomem *pds;
> > +
> > +		if (!pci_rom_header_valid(pdev, image, rom, size, true))
> >  			break;
> > +
> >  		/* get the PCI data structure and check its "PCIR" signature */
> >  		pds = image + readw(image + 24);
> > +		if (!pci_rom_data_struct_valid(pdev, pds, rom, size))
> >  			break;
> > +
> > +		last_image = !!(readb(pds + 21) & 0x80);
> 
> !!() is not needed.
> 
> 		last_image = readb(pds + 21) & 0x80;

And while at it, isn't this a bit field and

		last_image = readb(pds + 21) & BIT(7);

is even more descriptive? Please, check with specification and if it's
a (single) bit, also change this.

> >  		length = readw(pds + 16);
> >  		image += length * 512;
> > +
> > +		if (!pci_rom_header_valid(pdev, image, rom, size, last_image))
> >  			break;
> >  	} while (length && !last_image);

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2025-11-26 17:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-26 12:57 [PATCH v4] PCI: Check rom header and data structure addr before accessing Guixin Liu
2025-11-26 17:39 ` Andy Shevchenko
2025-11-26 17:42   ` Andy Shevchenko [this message]
2025-11-27  1:58     ` Guixin Liu
2025-11-27  1:57   ` Guixin Liu

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=aSc78vbl70YCWR56@smile.fi.intel.com \
    --to=andriy.shevchenko@intel.com \
    --cc=bhelgaas@google.com \
    --cc=kanie@linux.alibaba.com \
    --cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.