aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDongxiao Xu <dongxiao.xu@intel.com>2009-05-31 02:43:39 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-06-19 14:00:55 -0400
commit171df6381962b463e5aa8ff936eb3f995a56ce9e (patch)
tree55a7c6d792f4a8d450c72b0e6e7b3adf223ad285
parent36e844671cbdace27f0462a46cedde0a4d6b1001 (diff)
Staging: 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@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/staging/heci/io_heci.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/staging/heci/io_heci.c b/drivers/staging/heci/io_heci.c
index 619eeed87ea..53dc770727d 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,
277 } 277 }
278 goto end; 278 goto end;
279 } 279 }
280 spin_unlock_bh(&dev->device_lock);
281
280 spin_lock(&file_ext->file_lock); 282 spin_lock(&file_ext->file_lock);
283 spin_lock_bh(&dev->device_lock);
281 if (file_ext->state != HECI_FILE_CONNECTING) { 284 if (file_ext->state != HECI_FILE_CONNECTING) {
282 rets = -ENODEV; 285 rets = -ENODEV;
283 spin_unlock(&file_ext->file_lock);
284 spin_unlock_bh(&dev->device_lock); 286 spin_unlock_bh(&dev->device_lock);
287 spin_unlock(&file_ext->file_lock);
285 goto end; 288 goto end;
286 } 289 }
287 spin_unlock(&file_ext->file_lock);
288 /* prepare the output buffer */ 290 /* prepare the output buffer */
289 client = (struct heci_client *) res_msg.data; 291 client = (struct heci_client *) res_msg.data;
290 client->max_msg_length = dev->me_clients[i].props.max_msg_length; 292 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,
312 &dev->ctrl_wr_list.heci_cb.cb_list); 314 &dev->ctrl_wr_list.heci_cb.cb_list);
313 } 315 }
314 spin_unlock_bh(&dev->device_lock); 316 spin_unlock_bh(&dev->device_lock);
317 spin_unlock(&file_ext->file_lock);
315 err = wait_event_timeout(dev->wait_recvd_msg, 318 err = wait_event_timeout(dev->wait_recvd_msg,
316 (HECI_FILE_CONNECTED == file_ext->state 319 (HECI_FILE_CONNECTED == file_ext->state
317 || HECI_FILE_DISCONNECTED == file_ext->state), 320 || HECI_FILE_DISCONNECTED == file_ext->state),