From: Jiri Slaby <jslaby@suse.cz>
To: Joerg Roedel <joro@8bytes.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tty: Add missing lock in n_tty_write()
Date: Wed, 15 May 2013 17:03:17 +0200 [thread overview]
Message-ID: <5193A3B5.7010400@suse.cz> (raw)
In-Reply-To: <20130515105656.GI24440@8bytes.org>
On 05/15/2013 12:56 PM, Joerg Roedel wrote:
> The call of the tty->ops->write callback is protected by
> output_lock in all other places I looked at. So it seems the
> lock in this code-branch is missing, so take the output_lock
> there too.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Joerg Roedel <joro@8bytes.org>
> ---
> drivers/tty/n_tty.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
> index d655416..ffb94a4 100644
> --- a/drivers/tty/n_tty.c
> +++ b/drivers/tty/n_tty.c
> @@ -2058,10 +2058,14 @@ static ssize_t n_tty_write(struct tty_struct *tty, struct file *file,
> if (tty->ops->flush_chars)
> tty->ops->flush_chars(tty);
> } else {
> + struct n_tty_data *l = tty->disc_data;
> +
> + mutex_lock(&l->output_lock);
> while (nr > 0) {
> c = tty->ops->write(tty, b, nr);
> if (c < 0) {
> retval = c;
> + mutex_unlock(&l->output_lock);
> goto break_out;
> }
> if (!c)
> @@ -2069,6 +2073,7 @@ static ssize_t n_tty_write(struct tty_struct *tty, struct file *file,
> b += c;
> nr -= c;
> }
> + mutex_unlock(&l->output_lock);
> }
> if (!nr)
> break;
>
Are you fixing any bug here? output_lock does not protect
tty->ops->write on the other places, not tty->ops->write.
thanks,
--
js
suse labs
next prev parent reply other threads:[~2013-05-15 15:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-15 10:56 [PATCH] tty: Add missing lock in n_tty_write() Joerg Roedel
2013-05-15 15:03 ` Jiri Slaby [this message]
2013-05-15 15:47 ` Joerg Roedel
2013-05-15 18:45 ` Peter Hurley
2013-05-15 19:48 ` Joerg Roedel
2013-05-15 23:10 ` Peter Hurley
2013-05-17 11:48 ` Joerg Roedel
2013-05-17 19:08 ` Peter Hurley
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=5193A3B5.7010400@suse.cz \
--to=jslaby@suse.cz \
--cc=gregkh@linuxfoundation.org \
--cc=joro@8bytes.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