Skip to content

Commit 26d0832

Browse files
ISCAS-VulabNipaLocal
authored and
NipaLocal
committed
net/mlx5: Add error handling in mlx5_query_nic_vport_node_guid()
The function mlx5_query_nic_vport_node_guid() calls the function mlx5_query_nic_vport_context() but does not check its return value. A proper implementation can be found in mlx5_nic_vport_query_local_lb(). Add error handling for mlx5_query_nic_vport_context(). If it fails, free the out buffer via kvfree() and return error code. Fixes: 9efa752 ("net/mlx5_core: Introduce access functions to query vport RoCE fields") Cc: [email protected] # v4.5 Target: net Signed-off-by: Wentao Liang <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 93a3799 commit 26d0832

File tree

1 file changed

+6
-3
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+6
-3
lines changed

drivers/net/ethernet/mellanox/mlx5/core/vport.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,19 +465,22 @@ int mlx5_query_nic_vport_node_guid(struct mlx5_core_dev *mdev, u64 *node_guid)
465465
{
466466
u32 *out;
467467
int outlen = MLX5_ST_SZ_BYTES(query_nic_vport_context_out);
468+
int err;
468469

469470
out = kvzalloc(outlen, GFP_KERNEL);
470471
if (!out)
471472
return -ENOMEM;
472473

473-
mlx5_query_nic_vport_context(mdev, 0, out);
474+
err = mlx5_query_nic_vport_context(mdev, 0, out);
475+
if (err)
476+
goto out;
474477

475478
*node_guid = MLX5_GET64(query_nic_vport_context_out, out,
476479
nic_vport_context.node_guid);
477-
480+
out:
478481
kvfree(out);
479482

480-
return 0;
483+
return err;
481484
}
482485
EXPORT_SYMBOL_GPL(mlx5_query_nic_vport_node_guid);
483486

0 commit comments

Comments
 (0)