提交 5775f00e 编写于 作者: M Mario Six 提交者: Joe Hershberger

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: NMario Six <mario.six@gdsys.cc>
Acked-by: NJoe Hershberger <joe.hershberger@ni.com>
上级 d38de338
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册