diff options
author | Andrew Goodbody <andrew.goodbody@linaro.org> | 2025-08-05 16:45:49 +0100 |
---|---|---|
committer | Jerome Forissier <jerome.forissier@linaro.org> | 2025-08-18 14:08:57 +0200 |
commit | 0ce7fef9e2154d188bd50ae687fb666faac8fe7b (patch) | |
tree | 7ab62c6158480411eecbcde1135236c2e9986e85 /drivers/net/octeontx | |
parent | 62b4a482b943bc8173ac10a6c783e84d939b88bf (diff) |
net: octeontx: Free allocated memory on error
In octeontx_smi_probe if an error is detected then memory that was
allocated is not freed. Small refactor of the code to use a common
return and free memory. Also return -ENOMEM for an allocation failure.
This issue was found by Smatch.
Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Diffstat (limited to 'drivers/net/octeontx')
-rw-r--r-- | drivers/net/octeontx/smi.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/net/octeontx/smi.c b/drivers/net/octeontx/smi.c index 233c26f7319..217bcac2ce2 100644 --- a/drivers/net/octeontx/smi.c +++ b/drivers/net/octeontx/smi.c @@ -338,7 +338,8 @@ int octeontx_smi_probe(struct udevice *dev) if (!bus || !priv) { printf("Failed to allocate OcteonTX MDIO bus # %u\n", dev_seq(dev)); - return -1; + ret = -ENOMEM; + goto error_ret; } bus->read = octeontx_phy_read; @@ -355,9 +356,16 @@ int octeontx_smi_probe(struct udevice *dev) ret = mdio_register(bus); if (ret) - return ret; + goto error_ret; } return 0; + +error_ret: + if (bus) + free(bus); + if (priv) + free(priv); + return ret; } static const struct udevice_id octeontx_smi_ids[] = { |