tsec_initialize allocates a private driver structure using malloc.
Should the memory allocation of this private structure fail, the
function execution is aborted with a return 0, but the previously
allocated device structure is never freed, hence leaked.

Free the device structure in the error case.

Signed-off-by: Mario Six <mario....@gdsys.cc>
---
 drivers/net/tsec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
index aa261845f3..44140fb037 100644
--- a/drivers/net/tsec.c
+++ b/drivers/net/tsec.c
@@ -702,7 +702,9 @@ static int tsec_initialize(bd_t *bis, struct 
tsec_info_struct *tsec_info)
        priv = (struct tsec_private *)malloc(sizeof(*priv));
 
        if (!priv) {
+               free(dev);
                return 0;
+       }
 
        priv->regs = tsec_info->regs;
        priv->phyregs_sgmii = tsec_info->miiregs_sgmii;
-- 
2.11.0

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to