public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Ma Ke <make24@iscas.ac.cn>
Cc: jirislaby@kernel.org, u.kleine-koenig@pengutronix.de,
	tglx@linutronix.de, zhang_shurong@foxmail.com,
	B56683@freescale.com, cosmin.stoica@nxp.com,
	stefan-gabriel.mirea@nxp.com, Larisa.Grigore@nxp.com,
	matthew.nunez@nxp.com, linux-kernel@vger.kernel.org,
	linux-serial@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] tty: serial: Add a NULL check for of_node
Date: Wed, 14 Aug 2024 12:28:44 +0200	[thread overview]
Message-ID: <2024081416-gigabyte-stuck-2d4d@gregkh> (raw)
In-Reply-To: <20240814101520.17129-1-make24@iscas.ac.cn>

On Wed, Aug 14, 2024 at 06:15:20PM +0800, Ma Ke wrote:
> The pdev->dev.of_node can be NULL if the "serial" node is absent.

When will that happen?

> Add a NULL check for np to return an error in such cases.
> 
> Found by code review. Compile tested only.

So this never can happen?

> 
> Cc: stable@vger.kernel.org
> Fixes: 09864c1cdf5c ("tty: serial: Add linflexuart driver for S32V234")
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> ---
>  drivers/tty/serial/fsl_linflexuart.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/tty/serial/fsl_linflexuart.c b/drivers/tty/serial/fsl_linflexuart.c
> index e972df4b188d..f46f3c21ee1b 100644
> --- a/drivers/tty/serial/fsl_linflexuart.c
> +++ b/drivers/tty/serial/fsl_linflexuart.c
> @@ -811,6 +811,9 @@ static int linflex_probe(struct platform_device *pdev)
>  	struct resource *res;
>  	int ret;
>  
> +	if (!np)
> +		return -ENODEV;

Again, how can this happen?  Probe is only called if the platform device
is found, so why wouldn't the of_node pointer be set?

Don't check for impossible things.

thanks,

greg k-h

      reply	other threads:[~2024-08-14 10:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-14 10:15 [PATCH] tty: serial: Add a NULL check for of_node Ma Ke
2024-08-14 10:28 ` Greg KH [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=2024081416-gigabyte-stuck-2d4d@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=B56683@freescale.com \
    --cc=Larisa.Grigore@nxp.com \
    --cc=cosmin.stoica@nxp.com \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=make24@iscas.ac.cn \
    --cc=matthew.nunez@nxp.com \
    --cc=stable@vger.kernel.org \
    --cc=stefan-gabriel.mirea@nxp.com \
    --cc=tglx@linutronix.de \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=zhang_shurong@foxmail.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