From: Arjan van de Ven <arjan@infradead.org>
To: linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Anssi Hannula <anssi.hannula@gmail.com>,
Jussi Kivilinna <jussi.kivilinna@mbnet.fi>,
linux-input@vger.kernel.org
Subject: [PATCH] input: fix locking context in ml_ff_set_gain
Date: Sat, 31 Oct 2009 14:19:25 -0700 [thread overview]
Message-ID: <20091031141925.149c9874@infradead.org> (raw)
>From 177c4e7a84c40925605d485f6d5367deb44a84c8 Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <arjan@linux.intel.com>
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@linux.intel.com>
---
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
next reply other threads:[~2009-10-31 21:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-31 21:19 Arjan van de Ven [this message]
2009-11-02 6:38 ` [PATCH] input: fix locking context in ml_ff_set_gain Dmitry Torokhov
2009-11-03 5:44 ` Dmitry Torokhov
2009-11-03 5:53 ` Arjan van de Ven
2009-11-03 5:59 ` Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091031141925.149c9874@infradead.org \
--to=arjan@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=anssi.hannula@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=jussi.kivilinna@mbnet.fi \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).