Skip to content

Commit

Permalink
[SCSI] mpt2sas: fix double mutex lock in NON_BLOCKING state
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alexey Khoroshilov authored and James Bottomley committed Sep 24, 2012
1 parent f2b0599 commit b656688
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/scsi/mpt2sas/mpt2sas_ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b656688

Please sign in to comment.