From: Jiri Slaby <jslaby@suse.cz>
To: gregkh@suse.de
Cc: jirislaby@gmail.com, linux-kernel@vger.kernel.org,
linux-serial@vger.kernel.org, Jiri Slaby <jslaby@suse.cz>,
Alan Cox <alan@lxorguk.ukuu.org.uk>
Subject: [PATCH 4/7] Char: moxa, fix locking in moxa_write
Date: Wed, 20 Apr 2011 10:43:15 +0200 [thread overview]
Message-ID: <1303288998-31718-4-git-send-email-jslaby@suse.cz> (raw)
In-Reply-To: <1303288998-31718-1-git-send-email-jslaby@suse.cz>
moxa_write can be called from atomic context with irqs disabled (from
ppp_async_push). Don't enable interrupts by spin_unlock_bh as this
might cause deadlocks in the ppp layer.
Instead, use irqsave/irqrestore spin_lock functions.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/tty/moxa.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
index a290e9e..6255561 100644
--- a/drivers/tty/moxa.c
+++ b/drivers/tty/moxa.c
@@ -1202,14 +1202,15 @@ static int moxa_write(struct tty_struct *tty,
const unsigned char *buf, int count)
{
struct moxa_port *ch = tty->driver_data;
+ unsigned long flags;
int len;
if (ch == NULL)
return 0;
- spin_lock_bh(&moxa_lock);
+ spin_lock_irqsave(&moxa_lock, flags);
len = MoxaPortWriteData(tty, buf, count);
- spin_unlock_bh(&moxa_lock);
+ spin_unlock_irqrestore(&moxa_lock, flags);
set_bit(LOWWAIT, &ch->statusflags);
return len;
--
1.7.4.2
next prev parent reply other threads:[~2011-04-20 8:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-20 8:43 [PATCH 1/7] Char: nozomi, use GFP_KERNEL for kfifo allocation Jiri Slaby
2011-04-20 8:43 ` [PATCH 2/7] Char: nozomi, remove port.count checks Jiri Slaby
2011-04-20 8:43 ` [PATCH 3/7] Char: nozomi, remove useless tty_sem Jiri Slaby
2011-04-20 9:55 ` Jack Stone
2011-04-20 8:43 ` Jiri Slaby [this message]
2011-04-20 8:43 ` [PATCH 5/7] TTY: serial_core, remove invalid test Jiri Slaby
2011-04-20 8:43 ` [PATCH 6/7] TTY: serial_core, remove superfluous set_task_state Jiri Slaby
2011-04-20 8:43 ` [PATCH 7/7] TTY: tty_io, annotate locking functions Jiri Slaby
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=1303288998-31718-4-git-send-email-jslaby@suse.cz \
--to=jslaby@suse.cz \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=gregkh@suse.de \
--cc=jirislaby@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@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
all inboxes | Powered by JetHome®