Skip to contentSkip to conversation

mlx5: vdpa: fix possible uninitialized var

PATCH Superseded Jason Wang 2 participants 3 messages Jan 8, 2021 – Jan 12, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jason Wang

author
#0 lore raw

PATCH 1/1 mlx5: vdpa: fix possible uninitialized var

Upstream: posted

When compiling with -Werror=maybe-uninitialized, gcc may complains the possible uninitialized umem. Fix that.

---
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/vdpa/mlx5/net/mlx5_vnet.c +3 -0
index f1d54814db97..a6ad83d8d8e2 100644
@@ -706,6 +706,9 @@ static void umem_destroy(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue
 	case 3:
 		umem = &mvq->umem3;
 		break;
+	default:
+		WARN(1, "unsupported umem num %d\n", num);
+		return;
 	}
 
 	MLX5_SET(destroy_umem_in, in, opcode, MLX5_CMD_OP_DESTROY_UMEM);
Signature · 6 lines
2.25.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
#1 lore raw
Quoted 15 lines · Jason Wang

Upstream: posted

When compiling with -Werror=maybe-uninitialized, gcc may complains the possible uninitialized umem. Fix that.

---
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/vdpa/mlx5/net/mlx5_vnet.c +0 -0
index f1d54814db97..a6ad83d8d8e2 100644

drivers/vdpa/mlx5/net/mlx5_vnet.c static void umem_destroy(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue · line 714

Quoted 9 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +3 -0
@@ -706,6 +706,9 @@ static void umem_destroy(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue
 	case 3:
 		umem = &mvq->umem3;
 		break;
+	default:
+		WARN(1, "unsupported umem num %d\n", num);
+		return;
 	}
 
 	MLX5_SET(destroy_umem_in, in, opcode, MLX5_CMD_OP_DESTROY_UMEM);

Since the "default" case will never be executed, maybe it's better to just change "case 3:" to "default:" and avoid the WARN().

Quoted 3 lines
Signature · 1 line
2.25.1
author
#2 lore raw
Quoted 24 lines · Eli Cohen
Quoted 23 lines · Jason Wang

Upstream: posted

When compiling with -Werror=maybe-uninitialized, gcc may complains the possible uninitialized umem. Fix that.

---
  drivers/vdpa/mlx5/net/mlx5_vnet.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/vdpa/mlx5/net/mlx5_vnet.c +3 -0
index f1d54814db97..a6ad83d8d8e2 100644
@@ -706,6 +706,9 @@ static void umem_destroy(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue
  	case 3:
  		umem = &mvq->umem3;
  		break;
+	default:
+		WARN(1, "unsupported umem num %d\n", num);
+		return;
  	}
 
Quoted 3 lines

drivers/vdpa/mlx5/net/mlx5_vnet.c static void umem_destroy(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue · line 714

Quoted 1 line
drivers/vdpa/mlx5/net/mlx5_vnet.c +0 -0
  	MLX5_SET(destroy_umem_in, in, opcode, MLX5_CMD_OP_DESTROY_UMEM);

Since the "default" case will never be executed, maybe it's better to just change "case 3:" to "default:" and avoid the WARN().

Fine with me. Will do that in V3.

Thanks

Quoted 4 lines
Quoted 4 lines
Signature · 2 lines
-- 
2.25.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization