11f5207bJohn Levonvoid _spin_lock(int name);
21f5207bJohn Levonvoid _spin_unlock(int name);
31f5207bJohn Levonint _spin_trylock(int name);
41f5207bJohn Levon
51f5207bJohn Levonint a;
61f5207bJohn Levonint b;
71f5207bJohn Levonint func (void)
81f5207bJohn Levon{
91f5207bJohn Levon	int mylock = 1;
101f5207bJohn Levon	int mylock2 = 1;
111f5207bJohn Levon	int mylock3 = 1;
121f5207bJohn Levon
131f5207bJohn Levon	if (!_spin_trylock(mylock)) {
141f5207bJohn Levon		return;
151f5207bJohn Levon	}
161f5207bJohn Levon
171f5207bJohn Levon	_spin_unlock(mylock);
181f5207bJohn Levon	_spin_unlock(mylock2);
191f5207bJohn Levon
201f5207bJohn Levon	if (a)
211f5207bJohn Levon		_spin_unlock(mylock);
221f5207bJohn Levon	_spin_lock(mylock2);
231f5207bJohn Levon
241f5207bJohn Levon	if (!_spin_trylock(mylock3))
251f5207bJohn Levon		return;
261f5207bJohn Levon	return;
271f5207bJohn Levon}
281f5207bJohn Levon/*
291f5207bJohn Levon * check-name: Smatch locking #2
301f5207bJohn Levon * check-command: smatch --project=kernel sm_locking2.c
311f5207bJohn Levon *
321f5207bJohn Levon * check-output-start
3331ad075John Levonsm_locking2.c:21 func() error: double unlocked 'mylock' (orig line 17)
3431ad075John Levonsm_locking2.c:26 func() warn: inconsistent returns 'mylock3'.
3531ad075John Levon  Locked on  : 26
3631ad075John Levon  Unlocked on: 25
371f5207bJohn Levon * check-output-end
381f5207bJohn Levon */
39