Skip to content

Commit 11776cf

Browse files
Dan Carpenterkuba-moo
authored andcommitted
net/mlx5: DR, prevent potential error pointer dereference
The dr_domain_add_vport_cap() function generally returns NULL on error but sometimes we want it to return ERR_PTR(-EBUSY) so the caller can retry. The problem here is that "ret" can be either -EBUSY or -ENOMEM and if it's and -ENOMEM then the error pointer is propogated back and eventually dereferenced in dr_ste_v0_build_src_gvmi_qpn_tag(). Fixes: 11a45de ("net/mlx5: DR, Add support for SF vports") Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b04d86f commit 11776cf

File tree

1 file changed

+3
-1
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/steering/sws

1 file changed

+3
-1
lines changed

drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_domain.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,9 @@ dr_domain_add_vport_cap(struct mlx5dr_domain *dmn, u16 vport)
297297
if (ret) {
298298
mlx5dr_dbg(dmn, "Couldn't insert new vport into xarray (%d)\n", ret);
299299
kvfree(vport_caps);
300-
return ERR_PTR(ret);
300+
if (ret == -EBUSY)
301+
return ERR_PTR(-EBUSY);
302+
return NULL;
301303
}
302304

303305
return vport_caps;

0 commit comments

Comments
 (0)