1*1f5207b7SJohn Levon void *kmalloc(void); 2*1f5207b7SJohn Levon void free(void *); 3*1f5207b7SJohn Levon 4*1f5207b7SJohn Levon struct ture { 5*1f5207b7SJohn Levon int *a; 6*1f5207b7SJohn Levon }; 7*1f5207b7SJohn Levon 8*1f5207b7SJohn Levon struct ture *a; 9*1f5207b7SJohn Levon struct ture *b; func(void)10*1f5207b7SJohn Levonvoid func (void) 11*1f5207b7SJohn Levon { 12*1f5207b7SJohn Levon struct ture *aa; 13*1f5207b7SJohn Levon struct ture *ab; 14*1f5207b7SJohn Levon struct ture *ac; 15*1f5207b7SJohn Levon aa = kmalloc(); 16*1f5207b7SJohn Levon ab = kmalloc(); 17*1f5207b7SJohn Levon ac = kmalloc(); 18*1f5207b7SJohn Levon 19*1f5207b7SJohn Levon a = aa; 20*1f5207b7SJohn Levon if (ab) { 21*1f5207b7SJohn Levon free(ab); 22*1f5207b7SJohn Levon return; 23*1f5207b7SJohn Levon } 24*1f5207b7SJohn Levon free(ac); 25*1f5207b7SJohn Levon return; 26*1f5207b7SJohn Levon } 27*1f5207b7SJohn Levon /* 28*1f5207b7SJohn Levon * check-name: leak test #1 29*1f5207b7SJohn Levon * check-command: smatch sm_memory.c 30*1f5207b7SJohn Levon * 31*1f5207b7SJohn Levon * check-output-start 32*1f5207b7SJohn Levon sm_memory.c:22 func() warn: possible memory leak of 'ac' 33*1f5207b7SJohn Levon * check-output-end 34*1f5207b7SJohn Levon */ 35