Message ID | 20160921145919.13754-1-teg@jklm.no (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Wed, Sep 21, 2016 at 04:59:18PM +0200, Tom Gundersen wrote: > 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> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> > --- > 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 f2f6429..99e6751 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.9.3 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel
On 21 September 2016 at 15:59, Tom Gundersen <teg@jklm.no> wrote: > 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> > --- > 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 f2f6429..99e6751 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; > + From memory there should be no open-source drivers where this happens today. Either way, having a big WARN/OOPS would be better, imho, since it will point to the driver bug/issue (?). Regards, Emil
On Thu, Sep 22, 2016 at 8:28 AM, Emil Velikov <emil.l.velikov@gmail.com> wrote: > On 21 September 2016 at 15:59, Tom Gundersen <teg@jklm.no> wrote: >> 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> >> --- >> 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 f2f6429..99e6751 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; >> + > From memory there should be no open-source drivers where this happens > today. Either way, having a big WARN/OOPS would be better, imho, since > it will point to the driver bug/issue (?). Yeah, I only hit this during development, should not happen with any upstream drivers afaik. Feel free to drop this patch for now. Cheers, Tom
On Wed, Sep 21, 2016 at 7:59 AM, Tom Gundersen <teg@jklm.no> wrote: > 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> Thanks, applied to -misc Sean > --- > 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 f2f6429..99e6751 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.9.3 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index f2f6429..99e6751 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);
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> --- drivers/gpu/drm/drm_drv.c | 3 +++ 1 file changed, 3 insertions(+)