[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <2024081416-gigabyte-stuck-2d4d@gregkh>
Date: Wed, 14 Aug 2024 12:28:44 +0200
From: Greg KH <gregkh@...uxfoundation.org>
To: Ma Ke <make24@...as.ac.cn>
Cc: jirislaby@...nel.org, u.kleine-koenig@...gutronix.de,
tglx@...utronix.de, zhang_shurong@...mail.com, B56683@...escale.com,
cosmin.stoica@....com, stefan-gabriel.mirea@....com,
Larisa.Grigore@....com, matthew.nunez@....com,
linux-kernel@...r.kernel.org, linux-serial@...r.kernel.org,
stable@...r.kernel.org
Subject: Re: [PATCH] tty: serial: Add a NULL check for of_node
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@...r.kernel.org
> Fixes: 09864c1cdf5c ("tty: serial: Add linflexuart driver for S32V234")
> Signed-off-by: Ma Ke <make24@...as.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
Powered by blists - more mailing lists