Commit e4245ea8 authored by Chris Wilson's avatar Chris Wilson Committed by Daniel Vetter

drm: Prevent NULL deref in drm_name_info()

If a driver does not have a parent, or never sets the unique name for
itself, then we may proceed to chase a NULL dereference through
debugfs/.../name.

Testcase: igt/vgem_basic/debugfs
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1466448813-23340-1-git-send-email-chris@chris-wilson.co.uk
parent c001da4f
...@@ -51,17 +51,16 @@ int drm_name_info(struct seq_file *m, void *data) ...@@ -51,17 +51,16 @@ int drm_name_info(struct seq_file *m, void *data)
struct drm_minor *minor = node->minor; struct drm_minor *minor = node->minor;
struct drm_device *dev = minor->dev; struct drm_device *dev = minor->dev;
struct drm_master *master = minor->master; struct drm_master *master = minor->master;
if (!master)
return 0; seq_printf(m, "%s", dev->driver->name);
if (dev->dev)
if (master->unique) { seq_printf(m, " dev=%s", dev_name(dev->dev));
seq_printf(m, "%s %s %s\n", if (master && master->unique)
dev->driver->name, seq_printf(m, " master=%s", master->unique);
dev_name(dev->dev), master->unique); if (dev->unique)
} else { seq_printf(m, " unique=%s", dev->unique);
seq_printf(m, "%s %s\n", seq_printf(m, "\n");
dev->driver->name, dev_name(dev->dev));
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment