From: Alexey Khoroshilov Date: Tue, 28 Aug 2012 14:38:02 +0000 (+0400) Subject: [SCSI] mpt2sas: fix double mutex lock in NON_BLOCKING state X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b656688a90175d4c424a2f02264863ede7e82d7b;p=GitHub%2Fmt8127%2Fandroid_kernel_alcatel_ttab.git [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 Acked-by: "Sreekanth Reddy" Signed-off-by: James Bottomley --- 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, 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: