public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alan Cox <alan@linux.intel.com>
To: greg@kroah.com, linux-kernel@vger.kernel.org
Subject: [PATCH 05/12] isicom: fix deadlock on shutdown
Date: Wed, 18 Nov 2009 14:15:37 +0000	[thread overview]
Message-ID: <20091118141528.3346.41333.stgit@localhost.localdomain> (raw)
In-Reply-To: <20091118141354.3346.16910.stgit@localhost.localdomain>

Alexander Strakh <strakh@ispras.ru> reported

	KERNEL_VERSION: 2.6.31
	DESCRIBE:
Driver drivers/char/isicom.c might sleep in atomic  context, because it
calls 
tty_port_xmit_buf under spin_lock.

./drivers/char/isicom.c:
1307 static void isicom_hangup(struct tty_struct *tty)
1308 {
...
1315         spin_lock_irqsave(&port->card->card_lock, flags);
1316         isicom_shutdown_port(port);
...

Path to might_sleep macro from isicom_hangup:
1. isicom_hangup calls spin_lock_irqsave (drivers/char/isicom.c:1315) and
then 
calls isicom_shutdown_port.
2. isiscom_shutdown_port calls tty_port_free_xmit_buf at 
drivers/char/isicom.c:906
3. tty_port_free_xmit_buf calls mutex_lock at drivers/char/tty_port:48

Found by Linux Driver Verification Project.

Signed-off-by: Alan Cox <alan@linux.intel.com>
---

 drivers/char/isicom.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c
index 1e91c30..300d5bd 100644
--- a/drivers/char/isicom.c
+++ b/drivers/char/isicom.c
@@ -887,7 +887,6 @@ static void isicom_shutdown_port(struct isi_port *port)
 {
 	struct isi_board *card = port->card;
 
-	tty_port_free_xmit_buf(&port->port);
 	if (--card->count < 0) {
 		pr_dbg("isicom_shutdown_port: bad board(0x%lx) count %d.\n",
 			card->base, card->count);
@@ -927,6 +926,7 @@ static void isicom_shutdown(struct tty_port *port)
 	outw(card->port_status, card->base + 0x02);
 	isicom_shutdown_port(ip);
 	spin_unlock_irqrestore(&card->card_lock, flags);
+	tty_port_free_xmit_buf(port);
 }
 
 static void isicom_close(struct tty_struct *tty, struct file *filp)


  parent reply	other threads:[~2009-11-18 14:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-18 14:14 [PATCH 00/12] Series short description Alan Cox
2009-11-18 14:14 ` [PATCH 01/12] isicom: switch to the new tty_port_open helper Alan Cox
2009-11-18 14:14 ` [PATCH 02/12] isicom: sort out the board init logic Alan Cox
2009-11-18 14:15 ` [PATCH 03/12] mxser: use the tty_port_open method Alan Cox
2009-11-18 14:15 ` [PATCH 04/12] mxser: Use the new locking rules to fix setserial properly Alan Cox
2009-11-20 12:08   ` Dan Carpenter
2009-11-18 14:15 ` Alan Cox [this message]
2009-11-18 14:15 ` [PATCH 06/12] moxa: Use more tty_port ops Alan Cox
2009-11-18 14:15 ` [PATCH 07/12] moxa: rework the locking a bit Alan Cox
2009-11-18 14:16 ` [PATCH 08/12] Locking clean up Alan Cox
2009-11-18 14:16 ` [PATCH 09/12] moxa: Kill off the throttle method Alan Cox
2009-11-18 14:16 ` [PATCH 10/12] moxa: Fix modem op locking Alan Cox
2009-11-18 14:16 ` [PATCH 11/12] moxa: Kill the use of lock_kernel Alan Cox
2009-11-18 14:17 ` [PATCH 12/12] moxa: split open lock Alan Cox

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=20091118141528.3346.41333.stgit@localhost.localdomain \
    --to=alan@linux.intel.com \
    --cc=greg@kroah.com \
    --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