summaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
diff options
context:
space:
mode:
authorDima Chumak <dchumak@nvidia.com>2021-04-26 15:16:26 +0300
committerSaeed Mahameed <saeedm@nvidia.com>2021-07-27 16:10:05 -0700
commitb1c2f6312c5005c928a72e668bf305a589d828d4 (patch)
tree71d020e7f0b7ab43a3b2ab48ffd33444180db945 /drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
parent7f331bf0f060c2727e36d64f9b098b4ee5f3dfad (diff)
downloadlinux-b1c2f6312c5005c928a72e668bf305a589d828d4.tar.bz2
net/mlx5e: Fix nullptr in mlx5e_hairpin_get_mdev()
The result of __dev_get_by_index() is not checked for NULL and then gets dereferenced immediately. Also, __dev_get_by_index() must be called while holding either RTNL lock or @dev_base_lock, which isn't satisfied by mlx5e_hairpin_get_mdev() or its callers. This makes the underlying hlist_for_each_entry() loop not safe, and can have adverse effects in itself. Fix by using dev_get_by_index() and handling nullptr return value when ifindex device is not found. Update mlx5e_hairpin_get_mdev() callers to check for possible PTR_ERR() result. Fixes: 77ab67b7f0f9 ("net/mlx5e: Basic setup of hairpin object") Addresses-Coverity: ("Dereference null return value") Signed-off-by: Dima Chumak <dchumak@nvidia.com> Reviewed-by: Vlad Buslov <vladbu@nvidia.com> Reviewed-by: Roi Dayan <roid@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Diffstat (limited to 'drivers/net/ethernet/mellanox/mlx5/core/eswitch.h')
0 files changed, 0 insertions, 0 deletions