Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: ti: icssm-prueth: unwind cleanly in probe()

This error handling triggers a Smatch warning:

drivers/net/ethernet/ti/icssm/icssm_prueth.c:1574 icssm_prueth_probe()
warn: 'prueth->pru1' is an error pointer or valid

The warning is harmless because the pru_rproc_put() function has an
IS_ERR_OR_NULL() check built in. However, there is a small bug if
syscon_regmap_lookup_by_phandle() fails. In that case we should call
of_node_put() on eth0_node and eth1_node.

It's a little bit easier to re-write this code to only free things which
we know have been allocated successfully.

Fixes: 511f6c1ae093 ("net: ti: icssm-prueth: Adds ICSSM Ethernet driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Parvathi Pudi <parvathi@couthit.com>
Link: https://patch.msgid.link/aMvVagz8aBRxMvFn@stanley.mountain
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Dan Carpenter and committed by
Jakub Kicinski
5fc7fa74 b1e5dfa6

+14 -16
+14 -16
drivers/net/ethernet/ti/icssm/icssm_prueth.c
··· 1390 1390 prueth->mii_rt = syscon_regmap_lookup_by_phandle(np, "ti,mii-rt"); 1391 1391 if (IS_ERR(prueth->mii_rt)) { 1392 1392 dev_err(dev, "couldn't get mii-rt syscon regmap\n"); 1393 - return -ENODEV; 1393 + ret = PTR_ERR(prueth->mii_rt); 1394 + goto put_eth; 1394 1395 } 1395 1396 1396 1397 if (eth0_node) { ··· 1399 1398 if (IS_ERR(prueth->pru0)) { 1400 1399 ret = PTR_ERR(prueth->pru0); 1401 1400 dev_err_probe(dev, ret, "unable to get PRU0"); 1402 - goto put_pru; 1401 + goto put_eth; 1403 1402 } 1404 1403 } 1405 1404 ··· 1408 1407 if (IS_ERR(prueth->pru1)) { 1409 1408 ret = PTR_ERR(prueth->pru1); 1410 1409 dev_err_probe(dev, ret, "unable to get PRU1"); 1411 - goto put_pru; 1410 + goto put_pru0; 1412 1411 } 1413 1412 } 1414 1413 ··· 1416 1415 if (IS_ERR(pruss)) { 1417 1416 ret = PTR_ERR(pruss); 1418 1417 dev_err(dev, "unable to get pruss handle\n"); 1419 - goto put_pru; 1418 + goto put_pru1; 1420 1419 } 1421 1420 prueth->pruss = pruss; 1422 1421 ··· 1570 1569 } 1571 1570 pruss_put(prueth->pruss); 1572 1571 1573 - put_pru: 1574 - if (eth1_node) { 1575 - if (prueth->pru1) 1576 - pru_rproc_put(prueth->pru1); 1577 - of_node_put(eth1_node); 1578 - } 1579 - 1580 - if (eth0_node) { 1581 - if (prueth->pru0) 1582 - pru_rproc_put(prueth->pru0); 1583 - of_node_put(eth0_node); 1584 - } 1572 + put_pru1: 1573 + if (eth1_node) 1574 + pru_rproc_put(prueth->pru1); 1575 + put_pru0: 1576 + if (eth0_node) 1577 + pru_rproc_put(prueth->pru0); 1578 + put_eth: 1579 + of_node_put(eth1_node); 1580 + of_node_put(eth0_node); 1585 1581 1586 1582 return ret; 1587 1583 }