linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maxim Levitsky <mlevitsk@redhat.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jirislaby@kernel.org>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>
Subject: Re: [PATCH v1 1/3] serial: 8250_exar: Avoid NULL pointer dereference at ->exit()
Date: Tue, 08 Jun 2021 18:09:16 +0300	[thread overview]
Message-ID: <0dd7c5efd36aeeaa963643c482bf8ca3fcec69fa.camel@redhat.com> (raw)
In-Reply-To: <20210608144239.12697-1-andriy.shevchenko@linux.intel.com>

On Tue, 2021-06-08 at 17:42 +0300, Andy Shevchenko wrote:
> It's possible that during ->exit() the private_data is NULL,
> for instance when there was no GPIO device instantiated.
> Due to this we may not dereference it. Add a respective check.
> 
> Note, for now ->exit() only makes sense when GPIO device
> was instantiated, that's why we may use the check for entire
> function.
> 
> Fixes: 81171e7d31a6 ("serial: 8250_exar: Constify the software nodes")
> Reported-by: Maxim Levitsky <mlevitsk@redhat.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/tty/serial/8250/8250_exar.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
> index 2f49c580139b..bd4e9f6ac29c 100644
> --- a/drivers/tty/serial/8250/8250_exar.c
> +++ b/drivers/tty/serial/8250/8250_exar.c
> @@ -553,7 +553,11 @@ static void pci_xr17v35x_exit(struct pci_dev *pcidev)
>  {
>  	struct exar8250 *priv = pci_get_drvdata(pcidev);
>  	struct uart_8250_port *port = serial8250_get_port(priv->line[0]);
> -	struct platform_device *pdev = port->port.private_data;
> +	struct platform_device *pdev;
> +
> +	pdev = port->port.private_data;
> +	if (!pdev)
> +		return;
>  
>  	device_remove_software_node(&pdev->dev);
>  	platform_device_unregister(pdev);

Hi!

I just tested this patch and it does work!
Thanks a lot for fixing this that fast!

Tested-by: Maxim Levitsky <mlevitsk@redhat.com>

Best regards,
	Maxim Levitsky


      parent reply	other threads:[~2021-06-08 15:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-08 14:42 [PATCH v1 1/3] serial: 8250_exar: Avoid NULL pointer dereference at ->exit() Andy Shevchenko
2021-06-08 14:42 ` [PATCH v1 2/3] serial: 8250_exar: Extract exar_get_platform() helper Andy Shevchenko
2021-06-09 12:41   ` Greg Kroah-Hartman
2021-06-09 17:02     ` Andy Shevchenko
2021-06-08 14:42 ` [PATCH v1 3/3] serial: 8250_exar: Add ->unregister_gpio() callback Andy Shevchenko
2021-06-09 12:42   ` Greg Kroah-Hartman
2021-06-08 15:09 ` Maxim Levitsky [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=0dd7c5efd36aeeaa963643c482bf8ca3fcec69fa.camel@redhat.com \
    --to=mlevitsk@redhat.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=jirislaby@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).