Skip to contentSkip to conversation

idpf: remove redundant 'req_vec_chunks' NULL check

PATCH In review Pavan Kumar Linga 2 participants 2 messages Jul 24, 2024 – Aug 5, 2024

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

PATCH 1/1 idpf: remove redundant 'req_vec_chunks' NULL check

'req_vec_chunks' is used to store the vector info received from the device control plane. The memory for it is allocated in idpf_send_alloc_vectors_msg and returns an error if the memory allocation fails.

'req_vec_chunks' cannot be NULL in the later code flow. So remove the conditional check to extract the vector ids received from the device control plane.

Smatch static checker warning:

drivers/net/ethernet/intel/idpf/idpf_lib.c:417 idpf_intr_req()
error: we previously assumed 'adapter->req_vec_chunks' could be null (see line 360)

Fixes 4930fbf419a7 ("idpf: add core init and interrupt request")
---
 drivers/net/ethernet/intel/idpf/idpf_lib.c | 23 +++++-----------------
 1 file changed, 5 insertions(+), 18 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_lib.c +5 -18
index 5dbf2b4ba1b0..a56ea36fa8d5 100644
@@ -357,24 +357,11 @@ int idpf_intr_req(struct idpf_adapter *adapter)
 		goto free_msix;
 	}
 
-	if (adapter->req_vec_chunks) {
-		struct virtchnl2_vector_chunks *vchunks;
-		struct virtchnl2_alloc_vectors *ac;
-
-		ac = adapter->req_vec_chunks;
-		vchunks = &ac->vchunks;
-
-		num_vec_ids = idpf_get_vec_ids(adapter, vecids, total_vecs,
-					       vchunks);
-		if (num_vec_ids < v_actual) {
-			err = -EINVAL;
-			goto free_vecids;
-		}
-	} else {
-		int i;
-
-		for (i = 0; i < v_actual; i++)
-			vecids[i] = i;
+	num_vec_ids = idpf_get_vec_ids(adapter, vecids, total_vecs,
+				       &adapter->req_vec_chunks->vchunks);
+	if (num_vec_ids < v_actual) {
+		err = -EINVAL;
+		goto free_vecids;
 	}
 
 	for (vector = 0; vector < v_actual; vector++) {
Signature · 1 line
2.43.0
Tested-by on v1 1/1
#1 lore raw

drivers/net/ethernet/intel/idpf/idpf_lib.c

Quoted 38 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Pavan Kumar Linga
Sent: Wednesday, July 24, 2024 2:30 PM
To: [email protected]
Cc: Linga, Pavan Kumar <[email protected]>; Dan Carpenter <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-net] idpf: remove redundant 'req_vec_chunks' NULL check

'req_vec_chunks' is used to store the vector info received from the device control plane. The memory for it is allocated in idpf_send_alloc_vectors_msg and returns an error if the memory allocation fails.

'req_vec_chunks' cannot be NULL in the later code flow. So remove the conditional check to extract the vector ids received from the device control plane.

Smatch static checker warning:

drivers/net/ethernet/intel/idpf/idpf_lib.c:417 idpf_intr_req()
error: we previously assumed 'adapter->req_vec_chunks' could be null (see line 360)

Fixes 4930fbf419a7 ("idpf: add core init and interrupt request")
---
 drivers/net/ethernet/intel/idpf/idpf_lib.c | 23 +++++-----------------
 1 file changed, 5 insertions(+), 18 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_lib.c +0 -0
index 5dbf2b4ba1b0..a56ea36fa8d5 100644