Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: debugfs: make drm_debugfs_create_files() never fail

As stated before, there is no need to care if a debugfs function
succeeds or not, and no code logic in the kernel should ever change
based on a debugfs function return value, so make
drm_debugfs_create_files() never fail. If it encounters an
odd/rare/impossible error (i.e. out of memory, or a duplicate debugfs
filename to be created), just keep on moving as if nothing improper had
happened.

Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: Sean Paul <sean@poorly.run>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20190614095110.3716-2-gregkh@linuxfoundation.org

authored by

Greg Kroah-Hartman and committed by
Daniel Vetter
987d65d0 de85ec27

+6 -20
+6 -20
drivers/gpu/drm/drm_debugfs.c
··· 176 176 struct dentry *root, struct drm_minor *minor) 177 177 { 178 178 struct drm_device *dev = minor->dev; 179 - struct dentry *ent; 180 179 struct drm_info_node *tmp; 181 - int i, ret; 180 + int i; 182 181 183 182 for (i = 0; i < count; i++) { 184 183 u32 features = files[i].driver_features; ··· 187 188 continue; 188 189 189 190 tmp = kmalloc(sizeof(struct drm_info_node), GFP_KERNEL); 190 - if (tmp == NULL) { 191 - ret = -1; 192 - goto fail; 193 - } 194 - ent = debugfs_create_file(files[i].name, S_IFREG | S_IRUGO, 195 - root, tmp, &drm_debugfs_fops); 196 - if (!ent) { 197 - DRM_ERROR("Cannot create /sys/kernel/debug/dri/%pd/%s\n", 198 - root, files[i].name); 199 - kfree(tmp); 200 - ret = -1; 201 - goto fail; 202 - } 191 + if (tmp == NULL) 192 + continue; 203 193 204 194 tmp->minor = minor; 205 - tmp->dent = ent; 195 + tmp->dent = debugfs_create_file(files[i].name, 196 + S_IFREG | S_IRUGO, root, tmp, 197 + &drm_debugfs_fops); 206 198 tmp->info_ent = &files[i]; 207 199 208 200 mutex_lock(&minor->debugfs_lock); ··· 201 211 mutex_unlock(&minor->debugfs_lock); 202 212 } 203 213 return 0; 204 - 205 - fail: 206 - drm_debugfs_remove_files(files, count, minor); 207 - return ret; 208 214 } 209 215 EXPORT_SYMBOL(drm_debugfs_create_files); 210 216