From: Petr Machata <petrm@nvidia.com>
To: Natalia Petrova <n.petrova@fintech.ru>
Cc: Ido Schimmel <idosch@nvidia.com>, Petr Machata <petrm@nvidia.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <lvc-project@linuxtesting.org>
Subject: Re: [PATCH] mlxsw_spectrum_router: add check for return value of 'mlxsw_sp_rif_find_by_dev'
Date: Fri, 17 Feb 2023 18:38:06 +0100 [thread overview]
Message-ID: <877cwgb2tu.fsf@nvidia.com> (raw)
In-Reply-To: <20230217140939.487978-1-n.petrova@fintech.ru>
Natalia Petrova <n.petrova@fintech.ru> writes:
> Pointer 'rif' that contains the return value of 'mlxsw_sp_rif_find_by_dev'
> is checked for NULL to avoid possible undefined behavior below caused by
> dereference in 'mlxsw_sp_rif_destroy'.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: e4f3c1c17b6d ("mlxsw: spectrum_router: Implement common RIF core")
> Signed-off-by: Natalia Petrova <n.petrova@fintech.ru>
> ---
> drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
> index 2c4443c6b964..4f41b83d7c9e 100644
> --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
> +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
> @@ -8658,7 +8658,8 @@ static int mlxsw_sp_inetaddr_bridge_event(struct mlxsw_sp *mlxsw_sp,
> break;
> case NETDEV_DOWN:
> rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, l3_dev);
> - mlxsw_sp_rif_destroy(rif);
> + if (rif)
> + mlxsw_sp_rif_destroy(rif);
> break;
> }
I don't think this can happen. The corresponding NETDEV_UP is invoked
through address validator chain, so failures to create a RIF would be
vetoed. Furthermore the DOWN event itself is invoked by
mlxsw_sp_inetaddr_event(), where the invocation is contingent on
mlxsw_sp_rif_should_config(). That would be false if there's no RIF.
prev parent reply other threads:[~2023-02-17 17:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-17 14:09 [PATCH] mlxsw_spectrum_router: add check for return value of 'mlxsw_sp_rif_find_by_dev' Natalia Petrova
2023-02-17 17:38 ` Petr Machata [this message]
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=877cwgb2tu.fsf@nvidia.com \
--to=petrm@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=idosch@nvidia.com \
--cc=kuba@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).