1 struct sk_buff { 2 int valuable_information; 3 }; 4 struct foo { 5 int x; 6 }; 7 struct ture { 8 struct sk_buff *skb; 9 }; 10 11 struct wrap1 { 12 struct ture *a; 13 }; 14 struct wrap2 { 15 struct foo *c; 16 struct wrap1 *b; 17 }; 18 struct wrap3 { 19 struct foo *c; 20 }; 21 22 struct sk_buff *skb; 23 struct sk_buff **ptr; 24 struct ture *x; 25 struct ture xx; 26 struct wrap1 *u; 27 struct wrap2 *y; 28 struct wrap3 *z; 29 30 void kfree(void *data); 31 32 void func (void) 33 { 34 kfree(skb); 35 kfree(x->skb); 36 kfree(xx.skb); 37 kfree(y->c); 38 kfree(u->a->skb); 39 kfree(u->a); 40 kfree(y->b->a->skb); 41 kfree(z->c); 42 kfree(ptr); 43 } 44 /* 45 * check-name: kfree_skb() test 46 * check-command: smatch -p=kernel sm_skb.c 47 * 48 * check-output-start 49 sm_skb.c:34 func() error: use kfree_skb() here instead of kfree(skb) 50 sm_skb.c:35 func() error: use kfree_skb() here instead of kfree(x->skb) 51 sm_skb.c:36 func() error: use kfree_skb() here instead of kfree(xx.skb) 52 sm_skb.c:38 func() error: use kfree_skb() here instead of kfree(u->a->skb) 53 sm_skb.c:40 func() error: use kfree_skb() here instead of kfree(y->b->a->skb) 54 * check-output-end 55 */ 56