[<prev] [next>] [day] [month] [year] [list]
Message-ID: <EADF0A36011179459010BDF5142A457501C9BF2AE0@pdsmsx502.ccr.corp.intel.com>
Date: Sun, 31 May 2009 14:43:39 +0800
From: "Xu, Dongxiao" <dongxiao.xu@...el.com>
To: "greg@...ah.com" <greg@...ah.com>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"Nashif, Anas" <anas.nashif@...el.com>,
"Obara, Marcin" <marcin.obara@...el.com>
Subject: [Patch 02/08] Staging: heci - fix wrong order of device_lock and
file_lock
>From 5c4db44364f204d168d2bbb70310728a54aabcd7 Mon Sep 17 00:00:00 2001
From: Dongxiao Xu <dongxiao.xu@...el.com>
Date: Sun, 31 May 2009 22:44:09 +0800
Subject: [PATCH] heci: fix wrong order of device_lock and file_lock
When the two locks are nested, the code should always first acquire file_lock,
and then acquire device_lock in order not to generate dead-lock race.
Signed-off-by: Dongxiao Xu <dongxiao.xu@...el.com>
---
drivers/staging/heci/io_heci.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/heci/io_heci.c b/drivers/staging/heci/io_heci.c
index ff6d294..26882a2 100644
--- a/drivers/staging/heci/io_heci.c
+++ b/drivers/staging/heci/io_heci.c
@@ -277,14 +277,16 @@ int heci_ioctl_connect_client(struct iamt_heci_device *dev, int if_num,
}
goto end;
}
+ spin_unlock_bh(&dev->device_lock);
+
spin_lock(&file_ext->file_lock);
+ spin_lock_bh(&dev->device_lock);
if (file_ext->state != HECI_FILE_CONNECTING) {
rets = -ENODEV;
- spin_unlock(&file_ext->file_lock);
spin_unlock_bh(&dev->device_lock);
+ spin_unlock(&file_ext->file_lock);
goto end;
}
- spin_unlock(&file_ext->file_lock);
/* prepare the output buffer */
client = (struct heci_client *) res_msg.data;
client->max_msg_length = dev->me_clients[i].props.max_msg_length;
@@ -312,6 +314,7 @@ int heci_ioctl_connect_client(struct iamt_heci_device *dev, int if_num,
&dev->ctrl_wr_list.heci_cb.cb_list);
}
spin_unlock_bh(&dev->device_lock);
+ spin_unlock(&file_ext->file_lock);
err = wait_event_timeout(dev->wait_recvd_msg,
(HECI_FILE_CONNECTED == file_ext->state
|| HECI_FILE_DISCONNECTED == file_ext->state),
--
1.6.0.rc1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists