All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Vincent Whitchurch <vincent.whitchurch@axis.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jirislaby@kernel.org>,
	kernel@axis.com, Andy Shevchenko <andy.shevchenko@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] tty: Fix lookahead_buf crash with serdev
Date: Thu, 18 Aug 2022 15:00:50 +0300 (EEST)	[thread overview]
Message-ID: <67bee157-5aa9-213b-e7b8-38956a3884d9@linux.intel.com> (raw)
In-Reply-To: <20220818115026.2237893-1-vincent.whitchurch@axis.com>

[-- Attachment #1: Type: text/plain, Size: 1635 bytes --]

On Thu, 18 Aug 2022, Vincent Whitchurch wrote:

> Do not follow a NULL pointer if the tty_port_client_operations does not
> implement the ->lookahead_buf() callback, which is the case with
> serdev's ttyport.
> 
> Fixes: 6bb6fa6908ebd3 ("tty: Implement lookahead to process XON/XOFF timely")
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

-- 
 i.

> ---
> 
> Notes:
>     v2: Move more stuff into if block.
> 
>  drivers/tty/tty_buffer.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
> index 9fdecc795b6b..5e287dedce01 100644
> --- a/drivers/tty/tty_buffer.c
> +++ b/drivers/tty/tty_buffer.c
> @@ -470,7 +470,6 @@ static void lookahead_bufs(struct tty_port *port, struct tty_buffer *head)
>  
>  	while (head) {
>  		struct tty_buffer *next;
> -		unsigned char *p, *f = NULL;
>  		unsigned int count;
>  
>  		/*
> @@ -489,11 +488,16 @@ static void lookahead_bufs(struct tty_port *port, struct tty_buffer *head)
>  			continue;
>  		}
>  
> -		p = char_buf_ptr(head, head->lookahead);
> -		if (~head->flags & TTYB_NORMAL)
> -			f = flag_buf_ptr(head, head->lookahead);
> +		if (port->client_ops->lookahead_buf) {
> +			unsigned char *p, *f = NULL;
> +
> +			p = char_buf_ptr(head, head->lookahead);
> +			if (~head->flags & TTYB_NORMAL)
> +				f = flag_buf_ptr(head, head->lookahead);
> +
> +			port->client_ops->lookahead_buf(port, p, f, count);
> +		}
>  
> -		port->client_ops->lookahead_buf(port, p, f, count);
>  		head->lookahead += count;
>  	}
>  }
> 

      reply	other threads:[~2022-08-18 12:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-18 11:50 [PATCH v2] tty: Fix lookahead_buf crash with serdev Vincent Whitchurch
2022-08-18 12:00 ` Ilpo Järvinen [this message]

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=67bee157-5aa9-213b-e7b8-38956a3884d9@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=kernel@axis.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vincent.whitchurch@axis.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.