From 6098909cf2d0f9dda63aed3b6651d91f7ce6a473 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 30 Dec 2016 14:16:39 +0000 Subject: [PATCH] drm: Avoid NULL dereference of drm_device.dev 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 Cc: Gabriel Krisman Bertazi Cc: Daniel Vetter Signed-off-by: Daniel Vetter Link: http://patchwork.freedesktop.org/patch/msgid/20161230141639.10487-1-chris@chris-wilson.co.uk --- 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 135c746dc9c7..1b11ab628da7 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -762,7 +762,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.30.2