From c6bf811a0b55ab224fb2c75345641b4bb599475c Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Wed, 21 Sep 2016 16:59:18 +0200 Subject: [PATCH] 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 Signed-off-by: Sean Paul Link: http://patchwork.freedesktop.org/patch/msgid/20160921145919.13754-1-teg@jklm.no --- drivers/gpu/drm/drm_drv.c | 3 +++ 1 file changed, 3 insertions(+) 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); -- 2.39.5