[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AM0PR04MB49472A690A93C06CE27FFC4692429@AM0PR04MB4947.eurprd04.prod.outlook.com>
Date: Mon, 26 Apr 2021 12:09:46 +0000
From: Sherry Sun <sherry.sun@....com>
To: Fabio Estevam <festevam@...il.com>
CC: Greg KH <gregkh@...uxfoundation.org>,
"jirislaby@...nel.org" <jirislaby@...nel.org>,
"linux-serial@...r.kernel.org" <linux-serial@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
dl-linux-imx <linux-imx@....com>
Subject: RE: [PATCH 2/2] tty: serial: fsl_lpuart: fix the potential bug of
dereference null return value
Hi Fabio,
> Hi Sherry,
>
> On Mon, Apr 26, 2021 at 8:39 AM Sherry Sun <sherry.sun@....com> wrote:
>
> > > > + if (!sdata)
> > > > + return -ENODEV;
> > >
> > > How can sdata be NULL?
> >
> > Is it possible that a case forgot to set sdata? Then the value will be NULL,
> such as { .compatible = "fsl,imx8qxp-lpuart", }.
> > So I added the patch to avoid the kernel crash when run to sdata->reg_off
> directly. But I am not sure does it make sense.
>
> sdata comes directly from of_device_get_match_data().
>
> This driver only runs on DT platforms and the only way of being probed is
> when a compatible string matches, so it is not possible that sdata can be
> NULL.
Thanks for your reply.
I guess you mean the of_match_table will not be NULL since it contains compatible, right?
But for the lpuart data -- struct lpuart_soc_data, won’t it meet the NULL case? such as { .compatible = "fsl,imx8qxp-lpuart", }.
Here of_device_id won’t be NULL, but lpuart_soc_data Is NULL.
Best regards
Sherry
Powered by blists - more mailing lists