Skip to contentSkip to conversation

test_bpf: Fix NULL vs IS_ERR() check in test_skb_segment()

PATCH In review Dan Carpenter 4 participants 5 messages Mar 28, 2018 – Mar 29, 2018

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

PATCH 1/1 test_bpf: Fix NULL vs IS_ERR() check in test_skb_segment()

The skb_segment() function returns error pointers on error. It never returns NULL.

Fixes 76db8087c4c9 ("net: bpf: add a test for skb_segment in test_bpf module")
lib/test_bpf.c +1 -1
index b2badf6b23cd..8e157806df7a 100644
@@ -6649,7 +6649,7 @@ static __init int test_skb_segment(void)
 	}
 
 	segs = skb_segment(skb, features);
-	if (segs) {
+	if (!IS_ERR(segs)) {
 		kfree_skb_list(segs);
 		ret = 0;
 		pr_info("%s: success in skb_segment!", __func__);
Reviewed-by on v1 1/1
#2 lore raw
In reply to Dan Carpenter
Quoted 11 lines · Dan Carpenter

The skb_segment() function returns error pointers on error. It never returns NULL.

Fixes 76db8087c4c9 ("net: bpf: add a test for skb_segment in test_bpf module")
lib/test_bpf.c +0 -0
index b2badf6b23cd..8e157806df7a 100644

lib/test_bpf.c static __init int test_skb_segment(void) · line 6655

Quoted 8 lines
lib/test_bpf.c +1 -1
@@ -6649,7 +6649,7 @@ static __init int test_skb_segment(void)
  	}
 
  	segs = skb_segment(skb, features);
-	if (segs) {
+	if (!IS_ERR(segs)) {
  		kfree_skb_list(segs);
  		ret = 0;
  		pr_info("%s: success in skb_segment!", __func__);

Oh, my bad. Thanks for the fix!

#3 lore raw

Hi David,

Quoted 21 lines · Yonghong Song
Quoted 11 lines · Dan Carpenter

The skb_segment() function returns error pointers on error.  It never returns NULL.

Fixes 76db8087c4c9 ("net: bpf: add a test for skb_segment in test_bpf module")
lib/test_bpf.c +0 -0
index b2badf6b23cd..8e157806df7a 100644

lib/test_bpf.c static __init int test_skb_segment(void) · line 6654

Quoted 7 lines
lib/test_bpf.c +1 -1
@@ -6649,7 +6649,7 @@ static __init int test_skb_segment(void)
       }
         segs = skb_segment(skb, features);
-    if (segs) {
+    if (!IS_ERR(segs)) {
           kfree_skb_list(segs);
           ret = 0;
           pr_info("%s: success in skb_segment!", __func__);

Oh, my bad. Thanks for the fix!

Quoted 1 line

If you have a chance, please take this fix directly into your net-next tree since it also contains the original commit 76db8087c4c9 ("net: bpf: add a test for skb_segment in test_bpf module"), which is not in the bpf-next tree at this point.

Thanks a lot,
Daniel

maintainer
#4 lore raw

From: Daniel Borkmann <[email protected]>
Date: Wed, 28 Mar 2018 20:57:27 +0200

Quoted 4 lines

If you have a chance, please take this fix directly into your net-next tree since it also contains the original commit 76db8087c4c9 ("net: bpf: add a test for skb_segment in test_bpf module"), which is not in the bpf-next tree at this point.

Ok, done.