From: Leon Romanovsky <leon@kernel.org>
To: Ziyang Xuan <william.xuanziyang@huawei.com>
Cc: sgoutham@marvell.com, gakula@marvell.com, sbhatta@marvell.com,
hkelam@marvell.com, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v2] octeontx2-pf: Fix potential memory leak in otx2_init_tc()
Date: Sun, 4 Dec 2022 14:55:42 +0200 [thread overview]
Message-ID: <Y4yYzlzPKix6VloH@unreal> (raw)
In-Reply-To: <20221202110430.1472991-1-william.xuanziyang@huawei.com>
On Fri, Dec 02, 2022 at 07:04:30PM +0800, Ziyang Xuan wrote:
> In otx2_init_tc(), if rhashtable_init() failed, it does not free
> tc->tc_entries_bitmap which is allocated in otx2_tc_alloc_ent_bitmap().
>
> Fixes: 2e2a8126ffac ("octeontx2-pf: Unify flow management variables")
> Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
> ---
> v2:
> - Remove patch 2 which is not a problem, see the following link:
> https://www.spinics.net/lists/netdev/msg864159.html
> ---
> drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c
> index e64318c110fd..6a01ab1a6e6f 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c
> @@ -1134,7 +1134,12 @@ int otx2_init_tc(struct otx2_nic *nic)
> return err;
>
> tc->flow_ht_params = tc_flow_ht_params;
> - return rhashtable_init(&tc->flow_table, &tc->flow_ht_params);
> + err = rhashtable_init(&tc->flow_table, &tc->flow_ht_params);
> + if (err) {
> + kfree(tc->tc_entries_bitmap);
> + tc->tc_entries_bitmap = NULL;
Why do you set NULL here? All callers of otx2_init_tc() unwind error
properly.
> + }
> + return err;
> }
> EXPORT_SYMBOL(otx2_init_tc);
>
> --
> 2.25.1
>
next prev parent reply other threads:[~2022-12-04 12:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-02 11:04 [PATCH net v2] octeontx2-pf: Fix potential memory leak in otx2_init_tc() Ziyang Xuan
2022-12-04 12:55 ` Leon Romanovsky [this message]
2022-12-05 2:31 ` Ziyang Xuan (William)
2022-12-05 7:59 ` Leon Romanovsky
2022-12-05 11: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=Y4yYzlzPKix6VloH@unreal \
--to=leon@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gakula@marvell.com \
--cc=hkelam@marvell.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sbhatta@marvell.com \
--cc=sgoutham@marvell.com \
--cc=william.xuanziyang@huawei.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