[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230217140939.487978-1-n.petrova@fintech.ru>
Date: Fri, 17 Feb 2023 17:09:39 +0300
From: Natalia Petrova <n.petrova@...tech.ru>
To: Ido Schimmel <idosch@...dia.com>
CC: Natalia Petrova <n.petrova@...tech.ru>,
Petr Machata <petrm@...dia.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, <netdev@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <lvc-project@...uxtesting.org>
Subject: [PATCH] mlxsw_spectrum_router: add check for return value of 'mlxsw_sp_rif_find_by_dev'
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@...tech.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;
}
--
2.34.1
Powered by blists - more mailing lists