[PATCH] input: fix locking context in ml_ff_set_gain

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>From 177c4e7a84c40925605d485f6d5367deb44a84c8 Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <arjan@xxxxxxxxxxxxxxx>
Date: Sat, 31 Oct 2009 14:13:40 -0700
Subject: [PATCH] input: fix locking context in ml_ff_set_gain

the ml_ff_set_gain() function uses spin_lock_bh/spin_unlock_bh
for locking. Unfortunately, this function can be called with irqs
off:
vfs_write ->
evdev_write ->
input_inject_event (disables interrupts) ->
input_handle_event ->
input_ff_event ->
ml_ff_set_gain

and doing spin_unlock_bh() with interrupts off is not allowed
(and causes a nice warning as a result).

This patch fixes this by turning the locking into the _irqsave variant.

Reported-by: kerneloops.org 
Reported-by: http://www.kerneloops.org/searchweek.php?search=ml_ff_set_gain
Signed-off-by: Arjan van de Ven <arjan@xxxxxxxxxxxxxxx>
---
 drivers/input/ff-memless.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/input/ff-memless.c b/drivers/input/ff-memless.c
index 2d1415e..1a0bb4f 100644
--- a/drivers/input/ff-memless.c
+++ b/drivers/input/ff-memless.c
@@ -380,8 +380,9 @@ static void ml_ff_set_gain(struct input_dev *dev, u16 gain)
 {
 	struct ml_device *ml = dev->ff->private;
 	int i;
+	unsigned long flags;
 
-	spin_lock_bh(&ml->timer_lock);
+	spin_lock_irqsave(&ml->timer_lock, flags);
 
 	ml->gain = gain;
 
@@ -390,7 +391,7 @@ static void ml_ff_set_gain(struct input_dev *dev, u16 gain)
 
 	ml_play_effects(ml);
 
-	spin_unlock_bh(&ml->timer_lock);
+	spin_unlock_irqrestore(&ml->timer_lock, flags);
 }
 
 static int ml_ff_playback(struct input_dev *dev, int effect_id, int value)
-- 
1.6.2.5



-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux