From: Paolo Abeni <pabeni@redhat.com>
To: Ziyang Xuan <william.xuanziyang@huawei.com>,
sgoutham@marvell.com, gakula@marvell.com, sbhatta@marvell.com,
hkelam@marvell.com, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH net 2/2] octeontx2-pf: Fix a potential double free in otx2_sq_free_sqbs()
Date: Tue, 29 Nov 2022 13:03:56 +0100 [thread overview]
Message-ID: <a3c723c5a27a75924f9d2f4ecabe26c04add08f3.camel@redhat.com> (raw)
In-Reply-To: <047b210eb3b3a2e26703d8b0570a0a017789c169.1669361183.git.william.xuanziyang@huawei.com>
Hello,
On Fri, 2022-11-25 at 15:45 +0800, Ziyang Xuan wrote:
> otx2_sq_free_sqbs() will be called twice when goto "err_free_nix_queues"
> label in otx2_init_hw_resources(). The first calling is within
> otx2_free_sq_res() at "err_free_nix_queues" label, and the second calling
> is at later "err_free_sq_ptrs" label.
>
> In otx2_sq_free_sqbs(), If sq->sqb_ptrs[i] is not 0, the memory page it
> points to will be freed, and sq->sqb_ptrs[i] do not be assigned 0 after
> memory page be freed. If otx2_sq_free_sqbs() is called twice, the memory
> page pointed by sq->sqb_ptrs[i] will be freeed twice. To fix the bug,
> assign 0 to sq->sqb_ptrs[i] after memory page be freed.
>
> Fixes: caa2da34fd25 ("octeontx2-pf: Initialize and config queues")
> Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
> ---
> drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
> index 9e10e7471b88..5a25fe51d102 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
> @@ -1146,6 +1146,7 @@ void otx2_sq_free_sqbs(struct otx2_nic *pfvf)
> DMA_FROM_DEVICE,
> DMA_ATTR_SKIP_CPU_SYNC);
> put_page(virt_to_page(phys_to_virt(pa)));
> + sq->sqb_ptrs[sqb] = 0;
The above looks not needed...
> }
> sq->sqb_count = 0;
... as this will prevent the next invocation of otx2_sq_free_sqbs()
from traversing and freeing any sq->sqb_ptrs[] element.
Cheers,
Paolo
> }
next prev parent reply other threads:[~2022-11-29 12:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-25 7:45 [PATCH net 0/2] octeontx2-pf: Fix several bugs in exception paths Ziyang Xuan
2022-11-25 7:45 ` [PATCH net 1/2] octeontx2-pf: Fix potential memory leak in otx2_init_tc() Ziyang Xuan
2022-11-25 7:45 ` [PATCH net 2/2] octeontx2-pf: Fix a potential double free in otx2_sq_free_sqbs() Ziyang Xuan
2022-11-29 12:03 ` Paolo Abeni [this message]
2022-12-02 1:39 ` Ziyang Xuan (William)
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=a3c723c5a27a75924f9d2f4ecabe26c04add08f3.camel@redhat.com \
--to=pabeni@redhat.com \
--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=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;
as well as URLs for NNTP newsgroup(s).