* [patch] fix locking in mpt2sas_ctl.c
@ 2009-04-22 15:40 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2009-04-22 15:40 UTC (permalink / raw)
To: Eric.Moore; +Cc: support, DL-MPTFusionLinux, linux-scsi
With state == NON_BLOCKING, we would either return -EAGAIN or double lock.
The other thing in patch is:
- return -ENOMEM;
+ rc = -ENOMEM;
+ goto out;
Going to out releases the ioc->ctl_cmds.mutex lock and sets
ioc->ctl_cmds.status = MPT2_CMD_NOT_USED.
The patch is against 2.6.30-rc1. Sorry if that is too old...
Found by smatch (http://repo.or.cz/w/smatch.git). Compile tested only. :/
regards,
dan carpenter
Signed-off-by: Dan Carpenter <error27@gmail.com>
--- orig/drivers/scsi/mpt2sas/mpt2sas_ctl.c 2009-04-21 18:23:44.000000000 +0300
+++ devel/drivers/scsi/mpt2sas/mpt2sas_ctl.c 2009-04-21 18:38:41.000000000 +0300
@@ -550,7 +550,7 @@
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 && mutex_lock_interruptible(&ioc->ctl_cmds.mutex))
return -ERESTARTSYS;
if (ioc->ctl_cmds.status != MPT2_CMD_NOT_USED) {
@@ -1269,7 +1269,7 @@
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 && mutex_lock_interruptible(&ioc->ctl_cmds.mutex))
return -ERESTARTSYS;
if (ioc->ctl_cmds.status != MPT2_CMD_NOT_USED) {
@@ -1321,7 +1321,8 @@
" for diag buffers, requested size(%d)\n",
ioc->name, __func__, request_data_sz);
mpt2sas_base_free_smid(ioc, smid);
- return -ENOMEM;
+ rc = -ENOMEM;
+ goto out;
}
ioc->diag_buffer[buffer_type] = request_data;
ioc->diag_buffer_sz[buffer_type] = request_data_sz;
@@ -1623,7 +1624,7 @@
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 && mutex_lock_interruptible(&ioc->ctl_cmds.mutex))
return -ERESTARTSYS;
if (ioc->ctl_cmds.status != MPT2_CMD_NOT_USED) {
@@ -1787,7 +1788,7 @@
*/
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 && mutex_lock_interruptible(&ioc->ctl_cmds.mutex))
return -ERESTARTSYS;
if (ioc->ctl_cmds.status != MPT2_CMD_NOT_USED) {
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-04-22 15:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-22 15:40 [patch] fix locking in mpt2sas_ctl.c Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox