diff mbox

drm: Avoid NULL dereference of drm_device.dev

Message ID 20161230141639.10487-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson Dec. 30, 2016, 2:16 p.m. UTC
For a virtual device, drm_device.dev is NULL, so becareful not to
dereference it unconditionally in core code such as drm_dev_register().

Fixes: 75f6dfe3e652 ("drm: Deduplicate driver initialization message")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Daniel Vetter Dec. 30, 2016, 2:30 p.m. UTC | #1
On Fri, Dec 30, 2016 at 02:16:39PM +0000, Chris Wilson wrote:
> For a virtual device, drm_device.dev is NULL, so becareful not to
> dereference it unconditionally in core code such as drm_dev_register().
> 
> Fixes: 75f6dfe3e652 ("drm: Deduplicate driver initialization message")
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>

Welp, so much for assuming I don't need to CI simple core patches ... I
guess we should roll out bat CI to dri-devel asap, but for that there's
still way too much noise :(

Thanks for the quick fix, applied.
-Daniel
> ---
>  drivers/gpu/drm/drm_drv.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 24d2949fd80b..6285e42b42da 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -767,7 +767,8 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
>  
>  	DRM_INFO("Initialized %s %d.%d.%d %s for %s on minor %d\n",
>  		 driver->name, driver->major, driver->minor,
> -		 driver->patchlevel, driver->date, dev_name(dev->dev),
> +		 driver->patchlevel, driver->date,
> +		 dev->dev ? dev_name(dev->dev) : "virtual device",
>  		 dev->primary->index);
>  
>  	goto out_unlock;
> -- 
> 2.11.0
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 24d2949fd80b..6285e42b42da 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -767,7 +767,8 @@  int drm_dev_register(struct drm_device *dev, unsigned long flags)
 
 	DRM_INFO("Initialized %s %d.%d.%d %s for %s on minor %d\n",
 		 driver->name, driver->major, driver->minor,
-		 driver->patchlevel, driver->date, dev_name(dev->dev),
+		 driver->patchlevel, driver->date,
+		 dev->dev ? dev_name(dev->dev) : "virtual device",
 		 dev->primary->index);
 
 	goto out_unlock;