summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2016-09-21 16:59:18 +0200
committerSean Paul <seanpaul@chromium.org>2016-09-22 04:03:42 -0700
commitc6bf811a0b55ab224fb2c75345641b4bb599475c (patch)
treef7da9bef6b7d107efd85ede18571e5e76c9c612a
parentf566911ae1a30e486608e0e74593f4450e1a5ff2 (diff)
drm: Distinguish no name from ENOMEM in set_unique()
If passing name == NULL to drm_drv_set_unique() we now get -ENOMEM as kstrdup() returns NULL. Instead check for this explicitly and return -EINVAL if no name is provided. Signed-off-by: Tom Gundersen <teg@jklm.no> Signed-off-by: Sean Paul <seanpaul@chromium.org> Link: http://patchwork.freedesktop.org/patch/msgid/20160921145919.13754-1-teg@jklm.no
-rw-r--r--drivers/gpu/drm/drm_drv.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index f2f6429ab04f..99e67517b5c5 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -338,6 +338,9 @@ void drm_minor_release(struct drm_minor *minor)
static int drm_dev_set_unique(struct drm_device *dev, const char *name)
{
+ if (!name)
+ return -EINVAL;
+
kfree(dev->unique);
dev->unique = kstrdup(name, GFP_KERNEL);