From: Tom Gundersen Date: Wed, 21 Sep 2016 14:59:18 +0000 (+0200) Subject: drm: Distinguish no name from ENOMEM in set_unique() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c6bf811a0b55ab224fb2c75345641b4bb599475c;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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 --- 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);