Skip to contentSkip to conversation

cxgb4: remove redundant NULL check

PATCH In review Yang Li 3 participants 7 messages Jan 25, 2021 – Jan 27, 2021

Subsystems (3)
lore
Share & tools
lore

Yang Li

author
#0 lore raw

PATCH 1/4 cxgb4: remove redundant NULL check

Fix below warnings reported by coccicheck:
./drivers/net/ethernet/chelsio/cxgb4/clip_tbl.c:327:3-9: WARNING: NULL check before some freeing functions is not needed.

---
 drivers/net/ethernet/chelsio/cxgb4/clip_tbl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/clip_tbl.c +1 -2
index ce28820..12fcf84 100644
@@ -323,8 +323,7 @@ void t4_cleanup_clip_tbl(struct adapter *adap)
 	struct clip_tbl *ctbl = adap->clipt;
 
 	if (ctbl) {
-		if (ctbl->cl_list)
-			kvfree(ctbl->cl_list);
+		kvfree(ctbl->cl_list);
 		kvfree(ctbl);
 	}
 }
Signature · 1 line
1.8.3.1
maintainer
#1 lore raw
Quoted 6 lines · On Mon, 25 Jan 2021 17:47:22 +0800 Yang Li wrote:

Fix below warnings reported by coccicheck:
./drivers/net/ethernet/chelsio/cxgb4/clip_tbl.c:327:3-9: WARNING: NULL check before some freeing functions is not needed.

These 4 patches change the same driver in the same way, please squash them all into a single patch and resend.

Please use [PATCH net-next] as the subject tag.

author
#2 lore raw

PATCH 2/4 cxgb4: remove redundant NULL check

In reply to Yang Li

Fix below warnings reported by coccicheck:
./drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c:3558:2-8: WARNING: NULL check before some freeing functions is not needed.

---
 drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c +1 -2
index 75474f8..94eb8a6 100644
@@ -3554,8 +3554,7 @@ int cudbg_collect_qdesc(struct cudbg_init *pdbg_init,
 	}
 
 out_free:
-	if (data)
-		kvfree(data);
+	kvfree(data);
 
 #undef QDESC_GET_FLQ
 #undef QDESC_GET_RXQ
Signature · 1 line
1.8.3.1
author
#3 lore raw

PATCH 3/4 cxgb4: remove redundant NULL check

In reply to Yang Li

Fix below warnings reported by coccicheck:
./drivers/net/ethernet/chelsio/cxgb4/cxgb4_cudbg.c:161:2-7: WARNING:
NULL check before some freeing functions is not needed.

---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_cudbg.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_cudbg.c +1 -2
index 77648e4..dd66b24 100644
@@ -157,8 +157,7 @@ static int cudbg_alloc_compress_buff(struct cudbg_init *pdbg_init)
 
 static void cudbg_free_compress_buff(struct cudbg_init *pdbg_init)
 {
-	if (pdbg_init->compress_buff)
-		vfree(pdbg_init->compress_buff);
+	vfree(pdbg_init->compress_buff);
 }
 
 int cxgb4_cudbg_collect(struct adapter *adap, void *buf, u32 *buf_size,
Signature · 1 line
1.8.3.1
#4 lore raw
Quoted 15 lines · Yang Li

Fix below warnings reported by coccicheck:
./drivers/net/ethernet/chelsio/cxgb4/cxgb4_cudbg.c:161:2-7: WARNING:
NULL check before some freeing functions is not needed.

---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_cudbg.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_cudbg.c +0 -0
index 77648e4..dd66b24 100644

drivers/net/ethernet/chelsio/cxgb4/cxgb4_cudbg.c static int cudbg_alloc_compress_buff(struct cudbg_init *pdbg_init) · line 160

Quoted 4 lines
drivers/net/ethernet/chelsio/cxgb4/cxgb4_cudbg.c +0 -1
@@ -157,8 +157,7 @@ static int cudbg_alloc_compress_buff(struct cudbg_init *pdbg_init)
 
 static void cudbg_free_compress_buff(struct cudbg_init *pdbg_init)
 {
-	if (pdbg_init->compress_buff)

NAK. The above check is necessary.

pdbg_init->compress_buff may be NULL when Zlib is unavailable or when pdbg_init->compress_buff allocation fails, in which case we ignore error and continue without compression.

Quoted 8 lines
drivers/net/ethernet/chelsio/cxgb4/cxgb4_cudbg.c +1 -1
-		vfree(pdbg_init->compress_buff);
+	vfree(pdbg_init->compress_buff);
 }
 
 int cxgb4_cudbg_collect(struct adapter *adap, void *buf, u32 *buf_size,
Signature · 1 line
1.8.3.1
author
#5 lore raw

PATCH 4/4 cxgb4: remove redundant NULL check

In reply to Yang Li

Fix below warnings reported by coccicheck:
./drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:533:2-8: WARNING:
NULL check before some freeing functions is not needed.

---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c +2 -4
index dede025..97a811f 100644
@@ -525,12 +525,10 @@ struct cxgb4_tc_u32_table *cxgb4_init_tc_u32(struct adapter *adap)
 	for (i = 0; i < t->size; i++) {
 		struct cxgb4_link *link = &t->table[i];
 
-		if (link->tid_map)
-			kvfree(link->tid_map);
+		kvfree(link->tid_map);
 	}
 
-	if (t)
-		kvfree(t);
+	kvfree(t);
 
 	return NULL;
 }
Signature · 1 line
1.8.3.1
#6 lore raw
Quoted 15 lines · Yang Li

Fix below warnings reported by coccicheck:
./drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:533:2-8: WARNING:
NULL check before some freeing functions is not needed.

---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c +0 -0
index dede025..97a811f 100644

drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c struct cxgb4_tc_u32_table *cxgb4_init_tc_u32(struct adapter *adap) · line 529

Quoted 5 lines
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c +0 -2
@@ -525,12 +525,10 @@ struct cxgb4_tc_u32_table *cxgb4_init_tc_u32(struct adapter *adap)
 	for (i = 0; i < t->size; i++) {
 		struct cxgb4_link *link = &t->table[i];
 
-		if (link->tid_map)
-			kvfree(link->tid_map);

This patch is wrong. NAK.

What if the call to link->tid_map = kvcalloc() fails above? it still goes ahead and calls kvfree(link->tid_map), which is wrong.

Quoted 12 lines
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c +2 -2
+		kvfree(link->tid_map);
 	}
 
-	if (t)
-		kvfree(t);
+	kvfree(t);
 
 	return NULL;
 }
Signature · 1 line
1.8.3.1