net: dwc_eth_xgmac: Fix two Smatch reports
cover net: dwc_eth_xgmac: Fix two Smatch reports
Smatch reported two issues with this driver. Firstly a direct return instead of using an unwind goto and secondly a test for a condition guaranteed to be true by an earlier test.
---
Andrew Goodbody (2):
net: dwc_eth_xgmac: Use unwind goto on error
net: dwc_eth_xgmac_socfpga: Remove always true test
drivers/net/dwc_eth_xgmac.c | 2 +- drivers/net/dwc_eth_xgmac_socfpga.c | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-)
---
base-commit: ae5711f881100f856ead1e76832c32b92dba93c7
change-id: 20250804-dwc_eth-265d9bdc33fe
Best regards,
Signature · 1 line
Andrew Goodbody <[email protected]>
PATCH 1/2 net: dwc_eth_xgmac: Use unwind goto on error
In xgmac_probe there is a direct return after the point where unwind gotos start to be used to undo actions performed by earlier code. Use the appropriate unwind goto instead.
This issue was found by Smatch.
--- drivers/net/dwc_eth_xgmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dwc_eth_xgmac.c +1 -1
@@ -1102,7 +1102,7 @@ static int xgmac_probe(struct udevice *dev) ret = xgmac->config->ops->xgmac_start_clks (dev);if (ret <0 ) {pr_err ("%s xgmac_start_clks() failed: %d\n" , dev->name, ret); -return ret; + goto err_remove_resources_core; }if (IS_ENABLED (CONFIG_DM_ETH_PHY ))
Signature · 1 line
2.39.5
PATCH 2/2 net: dwc_eth_xgmac_socfpga: Remove always true test
In reply to Andrew GoodbodyIn dwxgmac_of_get_mac_mode there is a test for mac_mode which will return if false. After this point mac_mode is guaranteed to be true so there is no need to test for this. Remove that test.
This issue was found by Smatch.
--- drivers/net/dwc_eth_xgmac_socfpga.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/net/dwc_eth_xgmac_socfpga.c +3 -5
@@ -39,11 +39,9 @@ phy_interface_t dwxgmac_of_get_mac_mode(struct udevice *dev)if (!mac_mode)return PHY_INTERFACE_MODE_NA ; -if (mac_mode) { -for (i =0 ; i <PHY_INTERFACE_MODE_MAX ; i++) { -if (!strcmp (mac_mode, phy_interface_strings[i])) -return i; - } +for (i =0 ; i <PHY_INTERFACE_MODE_MAX ; i++) { +if (!strcmp (mac_mode, phy_interface_strings[i])) +return i; }return PHY_INTERFACE_MODE_NA ; }
Signature · 1 line
2.39.5