Skip to content

Commit 8d7ba71

Browse files
Keryerkuba-moo
authored andcommitted
rocker: fix memory leak in rocker_world_port_post_fini()
In rocker_world_port_pre_init(), rocker_port->wpriv is allocated with kzalloc(wops->port_priv_size, GFP_KERNEL). However, in rocker_world_port_post_fini(), the memory is only freed when wops->port_post_fini callback is set: if (!wops->port_post_fini) return; wops->port_post_fini(rocker_port); kfree(rocker_port->wpriv); Since rocker_ofdpa_ops does not implement port_post_fini callback (it is NULL), the wpriv memory allocated for each port is never freed when ports are removed. This leads to a memory leak of sizeof(struct ofdpa_port) bytes per port on every device removal. Fix this by always calling kfree(rocker_port->wpriv) regardless of whether the port_post_fini callback exists. Fixes: e420114 ("rocker: introduce worlds infrastructure") Signed-off-by: Kery Qi <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 709bbb0 commit 8d7ba71

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

drivers/net/ethernet/rocker/rocker_main.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,9 +1524,8 @@ static void rocker_world_port_post_fini(struct rocker_port *rocker_port)
15241524
{
15251525
struct rocker_world_ops *wops = rocker_port->rocker->wops;
15261526

1527-
if (!wops->port_post_fini)
1528-
return;
1529-
wops->port_post_fini(rocker_port);
1527+
if (wops->port_post_fini)
1528+
wops->port_post_fini(rocker_port);
15301529
kfree(rocker_port->wpriv);
15311530
}
15321531

0 commit comments

Comments
 (0)