octeontx2-af: support for coalescing KPU profiles
Hello Harman Kalra,
This is a semi-automatic email about new static checker warnings.
The patch 11c730bfbf5b: "octeontx2-af: support for coalescing KPU profiles" from May 27, 2021, leads to the following Smatch complaint:
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c:1624 npc_load_kpu_profile_fwdb()
warn: variable dereferenced before check 'rvu->kpu_prfl_addr' (see line 1619)drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
1608 static int npc_load_kpu_profile_fwdb(struct rvu *rvu, const char *kpu_profile) 1609 {
1610 int ret = -EINVAL;
1611 u64 prfl_sz;
1612
1613 /* Setting up the mapping for NPC profile image */ 1614 ret = npc_fwdb_prfl_img_map(rvu, &rvu->kpu_prfl_addr, &prfl_sz); 1615 if (ret < 0)
1616 goto done;
1617
1618 /* Detect if profile is coalesced or single KPU profile and load */
1619 ret = npc_fwdb_detect_load_prfl_img(rvu, prfl_sz, kpu_profile);
rvu->kpu_prfl_addr dereferenced inside function call
1620 if (ret == 0)
1621 goto done;
1622
1623 /* Cleaning up if KPU profile image from fwdata is not valid. */
1624 if (rvu->kpu_prfl_addr) {
^^^^^^^^^^^^^^^^^^Smatch isn't supposed to warn about places where the NULL check is *obviously* not required but I think I messed up something. Anyway, this NULL check doesn't make sense.
1625 iounmap(rvu->kpu_prfl_addr); 1626 rvu->kpu_prfl_addr = NULL; 1627 rvu->kpu_fwdata_sz = 0; 1628 rvu->kpu_fwdata = NULL;
1629 }
1630
1631 done:
1632 return ret;
1633 }
regards,
dan carpenter