[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <89568cc6-4251-4d59-9794-0a76adf3b7a8@linux.alibaba.com>
Date: Thu, 27 Nov 2025 09:58:31 +0800
From: Guixin Liu <kanie@...ux.alibaba.com>
To: Andy Shevchenko <andriy.shevchenko@...el.com>
Cc: Bjorn Helgaas <bhelgaas@...gle.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4] PCI: Check rom header and data structure addr before
accessing
在 2025/11/27 01:42, Andy Shevchenko 写道:
> 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.
>
Sure, changed in v5.
Best Regards
Guixin Liu
>>> length = readw(pds + 16);
>>> image += length * 512;
>>> +
>>> + if (!pci_rom_header_valid(pdev, image, rom, size, last_image))
>>> break;
>>> } while (length && !last_image);
Powered by blists - more mailing lists