linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mei: fix mismatch in mutex unlock-lock in mei_amthif_read()
@ 2012-12-21 21:44 Alexey Khoroshilov
  2012-12-23  9:22 ` Winkler, Tomas
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Khoroshilov @ 2012-12-21 21:44 UTC (permalink / raw)
  To: Tomas Winkler; +Cc: Alexey Khoroshilov, linux-kernel, ldv-project

Users of mei_amthif_read() expect it leaves dev->device_lock held,
while there is a path where mei_amthif_read() unlocks device_lock
and returns -ERESTARTSYS.

The patch move code locking device_lock back before the return.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
 drivers/misc/mei/amthif.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index 18794ae..e40ffd9 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -187,13 +187,13 @@ int mei_amthif_read(struct mei_device *dev, struct file *file,
 		wait_ret = wait_event_interruptible(dev->iamthif_cl.wait,
 			(cb = mei_amthif_find_read_list_entry(dev, file)));
 
+		/* Locking again the Mutex */
+		mutex_lock(&dev->device_lock);
+
 		if (wait_ret)
 			return -ERESTARTSYS;
 
 		dev_dbg(&dev->pdev->dev, "woke up from sleep\n");
-
-		/* Locking again the Mutex */
-		mutex_lock(&dev->device_lock);
 	}
 
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH] mei: fix mismatch in mutex unlock-lock in mei_amthif_read()
  2012-12-21 21:44 [PATCH] mei: fix mismatch in mutex unlock-lock in mei_amthif_read() Alexey Khoroshilov
@ 2012-12-23  9:22 ` Winkler, Tomas
  0 siblings, 0 replies; 2+ messages in thread
From: Winkler, Tomas @ 2012-12-23  9:22 UTC (permalink / raw)
  To: Alexey Khoroshilov, Greg KH (gregkh@linuxfoundation.org)
  Cc: linux-kernel, ldv-project



> 
> Users of mei_amthif_read() expect it leaves dev->device_lock held, while
> there is a path where mei_amthif_read() unlocks device_lock and returns -
> ERESTARTSYS.
> 
> The patch move code locking device_lock back before the return.
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Acked-by:   Tomas Winkler <tomas.winkler@intel.com>

Greg.  This should be eligible for 3.8.

Thanks
Tomas



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-12-23  9:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-21 21:44 [PATCH] mei: fix mismatch in mutex unlock-lock in mei_amthif_read() Alexey Khoroshilov
2012-12-23  9:22 ` Winkler, Tomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).