dect
/
linux-2.6
Archived
13
0
Fork 0

[SCSI] mpt2sas: fix double mutex lock in NON_BLOCKING state

If state is NON_BLOCKING and mutex_trylock is succeed,
the control flow goes to mutex_lock_interruptible() that is a deadlock.

[jejb: fixed coding style problems]
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Acked-by: "Sreekanth Reddy" <sreekanth.reddy@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
This commit is contained in:
Alexey Khoroshilov 2012-08-28 18:38:02 +04:00 committed by James Bottomley
parent f2b0599de5
commit b656688a90
1 changed files with 5 additions and 3 deletions

View File

@ -2181,10 +2181,12 @@ _ctl_ioctl_main(struct file *file, unsigned int cmd, void __user *arg,
return -EAGAIN;
state = (file->f_flags & O_NONBLOCK) ? NON_BLOCKING : BLOCKING;
if (state == NON_BLOCKING && !mutex_trylock(&ioc->ctl_cmds.mutex))
return -EAGAIN;
else if (mutex_lock_interruptible(&ioc->ctl_cmds.mutex))
if (state == NON_BLOCKING) {
if (!mutex_trylock(&ioc->ctl_cmds.mutex))
return -EAGAIN;
} else if (mutex_lock_interruptible(&ioc->ctl_cmds.mutex)) {
return -ERESTARTSYS;
}
switch (cmd) {
case MPT2IOCINFO: