Re: [PATCH] sc16is7xx: null ptr check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 31, 2015 at 12:01:27PM +0200, Sean Nyekjaer wrote:
> If a wrong compatible flag in specified, the of_match_device
> returning null.
> Implemented check and if NULL then returning -ENODEV.
> 
> Signed-off-by: Sean Nyekjaer <sean.nyekjaer@xxxxxxxxx>
> ---
>  drivers/tty/serial/sc16is7xx.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
> index 72ffd0d..2fce9fb 100644
> --- a/drivers/tty/serial/sc16is7xx.c
> +++ b/drivers/tty/serial/sc16is7xx.c
> @@ -1320,6 +1320,8 @@ static int sc16is7xx_spi_probe(struct spi_device *spi)
>  	if (spi->dev.of_node) {
>  		const struct of_device_id *of_id =
>  			of_match_device(sc16is7xx_dt_ids, &spi->dev);
> +	if (!of_id)
> +		return -ENODEV;

Did you see a problem here? I wonder if this can ever trigger. In the
commit log you wrote "If a wrong compatible flag in specified, ...", but
then the probe function isn't called at all, is it?

>  		devtype = (struct sc16is7xx_devtype *)of_id->data;
>  	} else {

Maybe the better fix is to remove the same if in the i2c probe routine?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux