[PATCH 2/3] drivers/ps3: Fix ps3-vuart null dereference

David Laight David.Laight at ACULAB.COM
Tue Sep 15 20:37:21 AEST 2015


From: Colin Ian King
> Sent: 14 September 2015 20:35
> On the unlikely event that drv is null, the current code will
> perform a null pointer dereference with it when printing a dev_dbg
> message.  Instead, the BUG_ON check on drv should be performed
> before we emit the dev_dbg message.
...
> diff --git a/drivers/ps3/ps3-vuart.c b/drivers/ps3/ps3-vuart.c
> index d6db822..632701a 100644
> --- a/drivers/ps3/ps3-vuart.c
> +++ b/drivers/ps3/ps3-vuart.c
> @@ -1000,12 +1000,11 @@ static int ps3_vuart_probe(struct ps3_system_bus_device *dev)
>  	dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__);
> 
>  	drv = ps3_system_bus_dev_to_vuart_drv(dev);
> +	BUG_ON(!drv);
> 
>  	dev_dbg(&dev->core, "%s:%d: (%s)\n", __func__, __LINE__,
>  		drv->core.core.name);
> 
> -	BUG_ON(!drv);
> -

Just delete the BUG_ON(), it is just as easy to debug the dereference.

	David



More information about the Linuxppc-dev mailing list