From: Simon Horman <horms@kernel.org>
To: Kery Qi <qikeyu2017@gmail.com>
Cc: jiri@resnulli.us, andrew+netdev@lunn.ch, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rocker: fix memory leak in rocker_world_port_post_fini()
Date: Mon, 26 Jan 2026 15:30:37 +0000 [thread overview]
Message-ID: <aXeInSbGB4KzpTHy@horms.kernel.org> (raw)
In-Reply-To: <20260123211030.2109-2-qikeyu2017@gmail.com>
On Sat, Jan 24, 2026 at 05:10:31AM +0800, Kery Qi wrote:
> 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: e420114eef4a ("rocker: introduce worlds infrastructure")
> Signed-off-by: Kery Qi <qikeyu2017@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
next prev parent reply other threads:[~2026-01-26 15:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-23 21:10 [PATCH] rocker: fix memory leak in rocker_world_port_post_fini() Kery Qi
2026-01-26 15:30 ` Simon Horman [this message]
2026-01-27 3:40 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aXeInSbGB4KzpTHy@horms.kernel.org \
--to=horms@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=qikeyu2017@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox