From: Manivannan Sadhasivam <mani@kernel.org>
To: Natalia Petrova <n.petrova@fintech.ru>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
linux-arm-msm@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org
Subject: Re: [PATCH] net: qrtr: free memory on error path in radix_tree_insert()
Date: Fri, 27 Jan 2023 11:25:09 +0530 [thread overview]
Message-ID: <20230127055509.GA7809@thinkpad> (raw)
In-Reply-To: <20230125134831.8090-1-n.petrova@fintech.ru>
On Wed, Jan 25, 2023 at 04:48:31PM +0300, Natalia Petrova wrote:
> Function radix_tree_insert() returns errors if the node hasn't
> been initialized and added to the tree.
>
> "kfree(node)" and return value "NULL" of node_get() help
> to avoid using unclear node in other calls.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: 0c2204a4ad71 ("net: qrtr: Migrate nameservice to kernel from userspace")
> Signed-off-by: Natalia Petrova <n.petrova@fintech.ru>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
This patch should also be backported to stable kernels. Could you please add,
Cc: <stable@vger.kernel.org> # 5.7
Thanks,
Mani
> ---
> net/qrtr/ns.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/net/qrtr/ns.c b/net/qrtr/ns.c
> index 1990d496fcfc..e595079c2caf 100644
> --- a/net/qrtr/ns.c
> +++ b/net/qrtr/ns.c
> @@ -83,7 +83,10 @@ static struct qrtr_node *node_get(unsigned int node_id)
>
> node->id = node_id;
>
> - radix_tree_insert(&nodes, node_id, node);
> + if (radix_tree_insert(&nodes, node_id, node)) {
> + kfree(node);
> + return NULL;
> + }
>
> return node;
> }
> --
> 2.34.1
>
--
மணிவண்ணன் சதாசிவம்
next prev parent reply other threads:[~2023-01-27 5:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-25 13:48 [PATCH] net: qrtr: free memory on error path in radix_tree_insert() Natalia Petrova
2023-01-25 15:04 ` Simon Horman
2023-01-27 5:55 ` Manivannan Sadhasivam [this message]
2023-01-28 8: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=20230127055509.GA7809@thinkpad \
--to=mani@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=n.petrova@fintech.ru \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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).