xref: /illumos-gate/usr/src/tools/smatch/src/validation/sm_netdevice.c (revision 1f5207b7604fb44407eb4342aff613f7c4508508)
1 
2 void kfree(void *);
3 
4 struct net_device {
5 	char *name;
6 };
7 
func(void)8 void func(void)
9 {
10 	struct net_device dev;
11 	struct net_device *dev2 = &dev;
12 	struct net_device **dev3 = &dev2;
13 	struct net_device *deva[10];
14 	struct net_device **devb[10];
15 	struct net_device ***devc = devb;
16 
17 	kfree(dev2);
18 	kfree(dev3);
19 	kfree(deva[0]);
20 	kfree(devb[0]);
21 	kfree(devc[0]);
22 }
23 /*
24  * check-name: free_netdev() vs kfree()
25  * check-command: smatch -p=kernel sm_netdevice.c
26  *
27  * check-output-start
28 sm_netdevice.c:17 func() error: use free_netdev() here instead of kfree(dev2)
29 sm_netdevice.c:19 func() error: use free_netdev() here instead of kfree(deva[0])
30  * check-output-end
31  */
32