Commit a5c71fdb authored by Daniel Vetter's avatar Daniel Vetter

drm: Handle dev->unique with drmm_

We need to add a drmm_kstrdup for this, but let's start somewhere.

This is not exactly perfect onion unwinding, but it's jsut a kfree so
doesn't really matter at all.
Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
Acked-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200323144950.3018436-21-daniel.vetter@ffwll.ch
parent 5dad34f3
...@@ -777,7 +777,6 @@ void drm_dev_fini(struct drm_device *dev) ...@@ -777,7 +777,6 @@ void drm_dev_fini(struct drm_device *dev)
mutex_destroy(&dev->filelist_mutex); mutex_destroy(&dev->filelist_mutex);
mutex_destroy(&dev->struct_mutex); mutex_destroy(&dev->struct_mutex);
drm_legacy_destroy_members(dev); drm_legacy_destroy_members(dev);
kfree(dev->unique);
} }
EXPORT_SYMBOL(drm_dev_fini); EXPORT_SYMBOL(drm_dev_fini);
...@@ -1059,8 +1058,8 @@ EXPORT_SYMBOL(drm_dev_unregister); ...@@ -1059,8 +1058,8 @@ EXPORT_SYMBOL(drm_dev_unregister);
*/ */
int drm_dev_set_unique(struct drm_device *dev, const char *name) int drm_dev_set_unique(struct drm_device *dev, const char *name)
{ {
kfree(dev->unique); drmm_kfree(dev, dev->unique);
dev->unique = kstrdup(name, GFP_KERNEL); dev->unique = drmm_kstrdup(dev, name, GFP_KERNEL);
return dev->unique ? 0 : -ENOMEM; return dev->unique ? 0 : -ENOMEM;
} }
......
...@@ -167,6 +167,22 @@ void *drmm_kmalloc(struct drm_device *dev, size_t size, gfp_t gfp) ...@@ -167,6 +167,22 @@ void *drmm_kmalloc(struct drm_device *dev, size_t size, gfp_t gfp)
} }
EXPORT_SYMBOL(drmm_kmalloc); EXPORT_SYMBOL(drmm_kmalloc);
char *drmm_kstrdup(struct drm_device *dev, const char *s, gfp_t gfp)
{
size_t size;
char *buf;
if (!s)
return NULL;
size = strlen(s) + 1;
buf = drmm_kmalloc(dev, size, gfp);
if (buf)
memcpy(buf, s, size);
return buf;
}
EXPORT_SYMBOL_GPL(drmm_kstrdup);
void drmm_kfree(struct drm_device *dev, void *data) void drmm_kfree(struct drm_device *dev, void *data)
{ {
struct drmres *dr_match = NULL, *dr; struct drmres *dr_match = NULL, *dr;
......
...@@ -24,6 +24,7 @@ static inline void *drmm_kzalloc(struct drm_device *dev, size_t size, gfp_t gfp) ...@@ -24,6 +24,7 @@ static inline void *drmm_kzalloc(struct drm_device *dev, size_t size, gfp_t gfp)
{ {
return drmm_kmalloc(dev, size, gfp | __GFP_ZERO); return drmm_kmalloc(dev, size, gfp | __GFP_ZERO);
} }
char *drmm_kstrdup(struct drm_device *dev, const char *s, gfp_t gfp);
void drmm_kfree(struct drm_device *dev, void *data); void drmm_kfree(struct drm_device *dev, void *data);
......
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