[PATCH] pcie: add pcie aspm registers check on root port and device.
Colin Ian King
colin.king at canonical.com
Fri Feb 10 08:47:50 UTC 2012
On 10/02/12 07:14, Alex Hung wrote:
> On 02/09/2012 07:31 PM, Colin Ian King wrote:
>
>>> +
>>> + if (line[3] == ' ') {
>>> + reg_val = strtol(line,&pEnd, 16);
>>> + for (i = 0; i< 16; i++) {
>>> + reg_val = strtol(pEnd + 1,&pEnd, 16);
>>> + cur->config[reg_loc] = reg_val;
>>> + reg_loc++;
>>
>> Hopefully we won't have > 256 bytes in PCI config space. Maybe we
>> should guard against thsi overflowing cur->config[]
> PCI configuration space will always be exact 256 bytes long (the
> addition pci extended space is exactly 4096 byte long, and it is from
> lspci -xxxx).
> Assuming lspci -xxx will not be changed to display extended
> configuration space, this should be safe.
How about "assume nothing" - stuff breaks and I like to avoid segfaults,
so how about something paranoid like:
for (i = 0; reg_loc < 256 && i < 16; i++)
cur->config[reg_loc++] = strtol(pEnd + 1,&pEnd, 16);
Colin
More information about the fwts-devel
mailing list