public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Xiao Jin <jin.xiao@intel.com>
To: gregkh@linuxfoundation.org, jslaby@suse.cz,
	linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	mingo@elte.hu, a.p.zijlstra@chello.nl, rusty@rustcorp.com.au,
	william.douglas@intel.com, sboyd@codeaurora.org
Cc: vincentx.pillet@intel.com
Subject: [PATCH] n_gsm.c: add tx_lock in gsm_send
Date: Wed, 19 Dec 2012 13:16:10 +0800	[thread overview]
Message-ID: <1355894170.9600.94.camel@xiaojin> (raw)

From: xiaojin <jin.xiao@intel.com>
Date: Wed, 19 Dec 2012 11:53:43 +0800
Subject: [PATCH] n_gsm.c: add tx_lock in gsm_send

All the call to gsm->output should be in the tx_lock,
that could avoid potential race from MUX level. But
we have no tx_lock in gsm_send.

This patch is to add tx_lock in gsm_send.

Signed-off-by: xiaojin <jin.xiao@intel.com>
---
 drivers/tty/n_gsm.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index dcc0430..4572117 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -573,6 +573,7 @@ static void gsm_send(struct gsm_mux *gsm, int addr,
int cr, int control)
 	int len;
 	u8 cbuf[10];
 	u8 ibuf[3];
+	unsigned long flags;
 
 	switch (gsm->encoding) {
 	case 0:
@@ -602,7 +603,9 @@ static void gsm_send(struct gsm_mux *gsm, int addr,
int cr, int control)
 		WARN_ON(1);
 		return;
 	}
+	spin_lock_irqsave(&gsm->tx_lock, flags);
 	gsm->output(gsm, cbuf, len);
+	spin_unlock_irqrestore(&gsm->tx_lock, flags);
 	gsm_print_packet("-->", addr, cr, control, NULL, 0);
 }
 
-- 
1.7.1




             reply	other threads:[~2012-12-20  6:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-19  5:16 Xiao Jin [this message]
2012-12-20 13:08 ` [PATCH] n_gsm.c: add tx_lock in gsm_send Alan Cox
  -- strict thread matches above, loose matches on Subject: below --
2012-12-20  0:38 Xiao Jin
2012-12-20 11:44 ` Alan Cox
2012-12-20 12:13   ` Xiao, Jin
2012-12-20 13:06     ` 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=1355894170.9600.94.camel@xiaojin \
    --to=jin.xiao@intel.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rusty@rustcorp.com.au \
    --cc=sboyd@codeaurora.org \
    --cc=vincentx.pillet@intel.com \
    --cc=william.douglas@intel.com \
    /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