summaryrefslogtreecommitdiff
path: root/drivers/net
diff options
context:
space:
mode:
authorMario Six <mario.six@gdsys.cc>2018-01-15 11:08:22 +0100
committerJoe Hershberger <joe.hershberger@ni.com>2018-02-26 15:28:43 -0600
commit5775f00e1206fd425609c26ee9a3620149e567ac (patch)
treef492e5c529199e0a5b5db77c0cc19443addf96d4 /drivers/net
parentd38de3380d1f1a9a97bc4d94ae2e5498a7cb5df4 (diff)
net: tsec: Fix memory leak in error path
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.six@gdsys.cc> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/tsec.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
index 071595218e..44140fb037 100644
--- a/drivers/net/tsec.c
+++ b/drivers/net/tsec.c
@@ -701,8 +701,10 @@ static int tsec_initialize(bd_t *bis, struct tsec_info_struct *tsec_info)
priv = (struct tsec_private *)malloc(sizeof(*priv));
- if (!priv)
+ if (!priv) {
+ free(dev);
return 0;
+ }
priv->regs = tsec_info->regs;
priv->phyregs_sgmii = tsec_info->miiregs_sgmii;