Skip to contentSkip to conversation

net/mlx5e: avoid uninitialized variable use

PATCH In review Arnd Bergmann 3 participants 3 messages Jul 10, 2019

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5e: avoid uninitialized variable use

clang points to a variable being used in an unexpected code path:

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c:251:2: warning: variable 'rec_seq_sz' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]

        default:
        ^~~~~~~
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c:255:46: note: uninitialized use occurs here
        skip_static_post = !memcmp(rec_seq, &rn_be, rec_seq_sz);
                                                    ^~~~~~~~~~

From looking at the function logic, it seems that there is no sensible way to continue here, so just return early and hope for the best.

Fixes d2ead1f360e8 ("net/mlx5e: Add kTLS TX HW offload support")
---
 drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c +1 -0
index 3f5f4317a22b..5c08891806f0 100644
@@ -250,6 +250,7 @@ tx_post_resync_params(struct mlx5e_txqsq *sq,
 	}
 	default:
 		WARN_ON(1);
+		return;
 	}
 
 	skip_static_post = !memcmp(rec_seq, &rn_be, rec_seq_sz);
Signature · 1 line
2.20.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 26 lines · Arnd Bergmann

clang points to a variable being used in an unexpected code path:

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c:251:2: warning: variable 'rec_seq_sz' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]

         default:
         ^~~~~~~
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c:255:46: note: uninitialized use occurs here
         skip_static_post = !memcmp(rec_seq, &rn_be, rec_seq_sz);
                                                     ^~~~~~~~~~

From looking at the function logic, it seems that there is no
sensible way to continue here, so just return early and hope for the best.

Fixes d2ead1f360e8 ("net/mlx5e: Add kTLS TX HW offload support")
---
  drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c | 1 +
  1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c +0 -0
index 3f5f4317a22b..5c08891806f0 100644

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c tx_post_resync_params(struct mlx5e_txqsq *sq, · line 256

Quoted 7 lines
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c +1 -0
@@ -250,6 +250,7 @@ tx_post_resync_params(struct mlx5e_txqsq *sq,
  	}
  	default:
  		WARN_ON(1);
+		return;
  	}
 
  	skip_static_post = !memcmp(rec_seq, &rn_be, rec_seq_sz);

Thanks!

#2 lore raw
In reply to Arnd Bergmann
Quoted 35 lines · Arnd Bergmann

clang points to a variable being used in an unexpected code path:

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c:251:2: warning: variable 'rec_seq_sz' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]

        default:
        ^~~~~~~
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c:255:46: note: uninitialized use occurs here
        skip_static_post = !memcmp(rec_seq, &rn_be, rec_seq_sz);
                                                    ^~~~~~~~~~

From looking at the function logic, it seems that there is no sensible way to continue here, so just return early and hope for the best.

Fixes d2ead1f360e8 ("net/mlx5e: Add kTLS TX HW offload support")
---
 drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c +1 -0
index 3f5f4317a22b..5c08891806f0 100644
@@ -250,6 +250,7 @@ tx_post_resync_params(struct mlx5e_txqsq *sq,
 	}
 	default:
 		WARN_ON(1);
+		return;
 	}
 
 	skip_static_post = !memcmp(rec_seq, &rn_be, rec_seq_sz);
Signature · 1 line
2.20.0

Looks like my identical patch got picked up in net-next:

https://git.kernel.org/davem/net-next/c/1ff2f0fa450ea4e4f87793d9ed513098ec6e12be

Good to know the fix was the same.

Cheers,
Nathan