diff options
author | Alexey Khoroshilov <khoroshilov@ispras.ru> | 2012-08-28 10:38:02 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2012-09-24 04:10:59 -0400 |
commit | b656688a90175d4c424a2f02264863ede7e82d7b (patch) | |
tree | d34e03ab53c0f226f98bffa5a392839c09a0d598 | |
parent | f2b0599de5450e11bc41be2432a161f86d816ae3 (diff) |
[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>
-rw-r--r-- | drivers/scsi/mpt2sas/mpt2sas_ctl.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/scsi/mpt2sas/mpt2sas_ctl.c b/drivers/scsi/mpt2sas/mpt2sas_ctl.c index 64254416a178..08685c4cf231 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_ctl.c +++ b/drivers/scsi/mpt2sas/mpt2sas_ctl.c | |||
@@ -2181,10 +2181,12 @@ _ctl_ioctl_main(struct file *file, unsigned int cmd, void __user *arg, | |||
2181 | return -EAGAIN; | 2181 | return -EAGAIN; |
2182 | 2182 | ||
2183 | state = (file->f_flags & O_NONBLOCK) ? NON_BLOCKING : BLOCKING; | 2183 | state = (file->f_flags & O_NONBLOCK) ? NON_BLOCKING : BLOCKING; |
2184 | if (state == NON_BLOCKING && !mutex_trylock(&ioc->ctl_cmds.mutex)) | 2184 | if (state == NON_BLOCKING) { |
2185 | return -EAGAIN; | 2185 | if (!mutex_trylock(&ioc->ctl_cmds.mutex)) |
2186 | else if (mutex_lock_interruptible(&ioc->ctl_cmds.mutex)) | 2186 | return -EAGAIN; |
2187 | } else if (mutex_lock_interruptible(&ioc->ctl_cmds.mutex)) { | ||
2187 | return -ERESTARTSYS; | 2188 | return -ERESTARTSYS; |
2189 | } | ||
2188 | 2190 | ||
2189 | switch (cmd) { | 2191 | switch (cmd) { |
2190 | case MPT2IOCINFO: | 2192 | case MPT2IOCINFO: |