11f5207bJohn Levonvoid _spin_lock(int name);
21f5207bJohn Levonvoid _spin_unlock(int name);
31f5207bJohn Levon
41f5207bJohn Levonint a, b, c;
51f5207bJohn Levon
61f5207bJohn Levonint func (void)
71f5207bJohn Levon{
81f5207bJohn Levon	int mylock = 1;
91f5207bJohn Levon	int mylock2 = 1;
101f5207bJohn Levon	int mylock3 = 1;
111f5207bJohn Levon
121f5207bJohn Levon	if (a) {
131f5207bJohn Levon		return;
141f5207bJohn Levon	}
151f5207bJohn Levon
161f5207bJohn Levon	_spin_lock(mylock);
171f5207bJohn Levon	_spin_unlock(mylock);
181f5207bJohn Levon
191f5207bJohn Levon	if (b) {
201f5207bJohn Levon		_spin_unlock(mylock2);
211f5207bJohn Levon		return;
221f5207bJohn Levon	}
231f5207bJohn Levon
241f5207bJohn Levon	if (c)
251f5207bJohn Levon		_spin_lock(mylock3);
261f5207bJohn Levon	return;
271f5207bJohn Levon}
281f5207bJohn Levon/*
291f5207bJohn Levon * check-name: Smatch locking #1
301f5207bJohn Levon * check-command: smatch --project=kernel --spammy sm_locking.c
311f5207bJohn Levon *
321f5207bJohn Levon * check-output-start
331f5207bJohn Levonsm_locking.c:26 func() warn: 'spin_lock:mylock3' is sometimes locked here and sometimes unlocked.
341f5207bJohn Levonsm_locking.c:26 func() warn: inconsistent returns 'spin_lock:mylock2'.
351f5207bJohn Levon  Locked on:   line 13
361f5207bJohn Levon               line 26
371f5207bJohn Levon  Unlocked on: line 21
381f5207bJohn Levon * check-output-end
391f5207bJohn Levon */
40