Re: Coverity CIDs 138749, 138750: cnb20le_res() unintended sign extension

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 3, 2014 at 1:56 PM, Bjorn Helgaas <bhelgaas@xxxxxxxxxx> wrote:
> Coverity complains about unintended sign extension in cnb20le_res() in
> arch/x86/pci/broadcom_bus.c here:
>
> 60        word1 = read_pci_config_16(bus, slot, func, 0xc4);
>  61        word2 = read_pci_config_16(bus, slot, func, 0xc6);
>  62        if (word1 != word2) {
>
> CID 138749 (#1 of 2): Unintended sign extension (SIGN_EXTENSION)
> sign_extension: Suspicious implicit sign extension: word1 with type
> unsigned short (16 bits, unsigned) is promoted in (word1 << 16) | 0 to
> type int (32 bits, signed), then sign-extended to type unsigned long
> long (64 bits, unsigned). If (word1 << 16) | 0 is greater than
> 0x7FFFFFFF, the upper bits of the result will all be 1.
>  63                res.start = (word1 << 16) | 0x0000;
>     CID 138750: Unintended sign extension (SIGN_EXTENSION) [select issue]
>  64                res.end   = (word2 << 16) | 0xffff;
>  65                res.flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
>  66                update_res(info, res.start, res.end, res.flags, 0);
>  67        }

could just add (resource_size_t) cast for word1 word2.

Thanks

Yinghai
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux