Why is Netronome driver using its own version of existing rte_pci_read_config?
And hard coding magic numbers for offsets.

This shows up as Coverity error
________________________________________________________________________________________________________
*** CID 277243:  Error handling issues  (CHECKED_RETURN)
/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c: 684 in nfp6000_set_interface()
678                      desc->busdev);
679     
680             fp = open(tmp_str, O_RDONLY);
681             if (!fp)
682                     return -1;
683     
>>>     CID 277243:  Error handling issues  (CHECKED_RETURN)
>>>     Calling "lseek(fp, 340L, 0)" without checking return value. This 
>>> library function may fail and return an error code.  
684             lseek(fp, 0x154, SEEK_SET);
685     
686             if (read(fp, &tmp, sizeof(tmp)) != sizeof(tmp)) {
687                     printf("error reading config file for interface\n");
688                     return -1;
689  


static int
nfp6000_set_model(struct nfp_pcie_user *desc, struct nfp_cpp *cpp)
{
        char tmp_str[80];
        uint32_t tmp;
        int fp;

        snprintf(tmp_str, sizeof(tmp_str), "%s/%s/config", PCI_DEVICES,
                 desc->busdev);

        fp = open(tmp_str, O_RDONLY);
        if (!fp)
                return -1;

        lseek(fp, 0x2e, SEEK_SET);

        if (read(fp, &tmp, sizeof(tmp)) != sizeof(tmp)) {
                printf("Error reading config file for model\n");
                return -1;
        }

        tmp = tmp << 16;

Reply via email to