From: Roi Dayan <roid@nvidia.com>
To: Colin Ian King <colin.i.king@gmail.com>,
Saeed Mahameed <saeedm@nvidia.com>,
Leon Romanovsky <leon@kernel.org>,
"David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
<netdev@vger.kernel.org>, <linux-rdma@vger.kernel.org>
Cc: <kernel-janitors@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<llvm@lists.linux.dev>
Subject: Re: [PATCH] net/mlx5e: Fix return of a kfree'd object instead of NULL
Date: Fri, 25 Feb 2022 14:14:12 +0200 [thread overview]
Message-ID: <331ea6e1-a8cb-3076-0dc8-385c53ab379c@nvidia.com> (raw)
In-Reply-To: <20220224221525.147744-1-colin.i.king@gmail.com>
On 2022-02-25 12:15 AM, Colin Ian King wrote:
> Currently in the case where parse_attr fails to be allocated the memory
> pointed to by attr2 is kfree'd but the non-null pointer attr2 is returned
> and a potential use of a kfree'd object can occur. Fix this by returning
> NULL to indicate a memory allocation error.
>
> Addresses issue found by clang-scan:
> drivers/net/ethernet/mellanox/mlx5/core/en_tc.c:3401:3: warning: Use of
> memory after it is freed [unix.Malloc]
>
> Fixes: 8300f225268b ("net/mlx5e: Create new flow attr for multi table actions")
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
> drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> index 76a015dfc5fc..c0776a4a3845 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> @@ -3398,7 +3398,7 @@ mlx5e_clone_flow_attr_for_post_act(struct mlx5_flow_attr *attr,
> if (!attr2 || !parse_attr) {
> kvfree(parse_attr);
> kfree(attr2);
> - return attr2;
> + return NULL;
> }
>
> memcpy(attr2, attr, attr_sz);
thanks!
Reviewed-by: Roi Dayan <roid@nvidia.com>
next prev parent reply other threads:[~2022-02-25 12:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-24 22:15 Colin Ian King
2022-02-25 12:14 ` Roi Dayan [this message]
2022-03-01 7:11 ` Saeed Mahameed
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=331ea6e1-a8cb-3076-0dc8-385c53ab379c@nvidia.com \
--to=roid@nvidia.com \
--cc=colin.i.king@gmail.com \
--cc=davem@davemloft.net \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=netdev@vger.kernel.org \
--cc=saeedm@nvidia.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
all inboxes | Powered by JetHome®