Skip to contentSkip to conversation

liquidio: remove unnecessary NULL check before kfree in delete_glists

PATCH Applied Gustavo A. R. Silva 3 participants 6 messages Oct 17, 2017 – Oct 19, 2017

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

PATCH 1/2 liquidio: remove unnecessary NULL check before kfree in delete_glists

NULL check before freeing functions like kfree is not needed.

This issue was detected with the help of Coccinelle.

---
This code was tested by compilation only.

 drivers/net/ethernet/cavium/liquidio/lio_vf_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/cavium/liquidio/lio_vf_main.c +1 -2
index 2e993ce..e4a112c 100644
@@ -435,8 +435,7 @@ static void delete_glists(struct lio *lio)
 		do {
 			g = (struct octnic_gather *)
 			    list_delete_head(&lio->glist[i]);
-			if (g)
-				kfree(g);
+			kfree(g);
 		} while (g);
 
 		if (lio->glists_virt_base && lio->glists_virt_base[i] &&
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/2 liquidio: mark expected switch fall-through in octeon_destroy_resources

In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through.

---
This code was tested by compilation only (GCC 7.2.0 was used). Please, verify if the actual intention of the code is to fall through.

 drivers/net/ethernet/cavium/liquidio/lio_vf_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/cavium/liquidio/lio_vf_main.c +1 -1
index e4a112c..4c3b568 100644
@@ -747,7 +747,7 @@ static void octeon_destroy_resources(struct octeon_device *oct)
 
 		if (lio_wait_for_oq_pkts(oct))
 			dev_err(&oct->pci_dev->dev, "OQ had pending packets\n");
-
+		/* fall through */
 	case OCT_DEV_INTR_SET_DONE:
 		/* Disable interrupts  */
 		oct->fn_list.disable_interrupt(oct, OCTEON_ALL_INTR);
Signature · 1 line
2.7.4
Acked-by on v1 1/2
#4 lore raw
In reply to Gustavo A. R. Silva
Quoted 28 lines · Gustavo A. R. Silva

NULL check before freeing functions like kfree is not needed.

This issue was detected with the help of Coccinelle.

---
This code was tested by compilation only.

 drivers/net/ethernet/cavium/liquidio/lio_vf_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/cavium/liquidio/lio_vf_main.c +1 -2
index 2e993ce..e4a112c 100644
@@ -435,8 +435,7 @@ static void delete_glists(struct lio *lio)
 		do {
 			g = (struct octnic_gather *)
 			    list_delete_head(&lio->glist[i]);
-			if (g)
-				kfree(g);
+			kfree(g);
 		} while (g);
 
 		if (lio->glists_virt_base && lio->glists_virt_base[i] &&
Signature · 1 line
2.7.4
Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] liquidio: mark expected switch fall-through in octeon_destroy_resources

In reply to Gustavo A. R. Silva
Quoted 27 lines · Gustavo A. R. Silva

In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through.

---
This code was tested by compilation only (GCC 7.2.0 was used). Please, verify if the actual intention of the code is to fall through.

 drivers/net/ethernet/cavium/liquidio/lio_vf_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/cavium/liquidio/lio_vf_main.c +1 -1
index e4a112c..4c3b568 100644
@@ -747,7 +747,7 @@ static void octeon_destroy_resources(struct octeon_device *oct)
 
 		if (lio_wait_for_oq_pkts(oct))
 			dev_err(&oct->pci_dev->dev, "OQ had pending packets\n");
-
+		/* fall through */
 	case OCT_DEV_INTR_SET_DONE:
 		/* Disable interrupts  */
 		oct->fn_list.disable_interrupt(oct, OCTEON_ALL_INTR);
Signature · 1 line
2.7.4