mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-27 09:02:06 +00:00
net: marvell: prestera: fix memory leak in prestera_rxtx_switch_init()
[ Upstream commit519b58bbfa
] When prestera_sdma_switch_init() failed, the memory pointed to by sw->rxtx isn't released. Fix it. Only be compiled, not be tested. Fixes:501ef3066c
("net: marvell: prestera: Add driver for Prestera family ASIC devices") Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com> Reviewed-by: Vadym Kochan <vadym.kochan@plvision.eu> Link: https://lore.kernel.org/r/20221108025607.338450-1-shaozhengchao@huawei.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
f1da48a0b7
commit
34b4998d25
1 changed files with 6 additions and 1 deletions
|
@ -776,6 +776,7 @@ tx_done:
|
||||||
int prestera_rxtx_switch_init(struct prestera_switch *sw)
|
int prestera_rxtx_switch_init(struct prestera_switch *sw)
|
||||||
{
|
{
|
||||||
struct prestera_rxtx *rxtx;
|
struct prestera_rxtx *rxtx;
|
||||||
|
int err;
|
||||||
|
|
||||||
rxtx = kzalloc(sizeof(*rxtx), GFP_KERNEL);
|
rxtx = kzalloc(sizeof(*rxtx), GFP_KERNEL);
|
||||||
if (!rxtx)
|
if (!rxtx)
|
||||||
|
@ -783,7 +784,11 @@ int prestera_rxtx_switch_init(struct prestera_switch *sw)
|
||||||
|
|
||||||
sw->rxtx = rxtx;
|
sw->rxtx = rxtx;
|
||||||
|
|
||||||
return prestera_sdma_switch_init(sw);
|
err = prestera_sdma_switch_init(sw);
|
||||||
|
if (err)
|
||||||
|
kfree(rxtx);
|
||||||
|
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
void prestera_rxtx_switch_fini(struct prestera_switch *sw)
|
void prestera_rxtx_switch_fini(struct prestera_switch *sw)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue