drm/amdgpu: fix ras ctrl debugfs node leak
authorGuchun Chen <guchun.chen@amd.com>
Mon, 16 Sep 2019 05:42:46 +0000 (13:42 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 16 Sep 2019 20:30:38 +0000 (15:30 -0500)
Use debugfs_remove_recursive to remove the whole debugfs
directory instead of removing the node one by one.

Signed-off-by: Guchun Chen <guchun.chen@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h

index faf6863ca78507d34f2ad86a148d074bf8fef7a6..daf9ac0b711f9bc8e61c78267987382fe4be6389 100644 (file)
@@ -980,10 +980,10 @@ static void amdgpu_ras_debugfs_create_ctrl_node(struct amdgpu_device *adev)
        struct drm_minor *minor = adev->ddev->primary;
 
        con->dir = debugfs_create_dir("ras", minor->debugfs_root);
-       con->ent = debugfs_create_file("ras_ctrl", S_IWUGO | S_IRUGO, con->dir,
-                                      adev, &amdgpu_ras_debugfs_ctrl_ops);
-       con->ent = debugfs_create_file("ras_eeprom_reset", S_IWUGO | S_IRUGO, con->dir,
-                                              adev, &amdgpu_ras_debugfs_eeprom_ops);
+       debugfs_create_file("ras_ctrl", S_IWUGO | S_IRUGO, con->dir,
+                               adev, &amdgpu_ras_debugfs_ctrl_ops);
+       debugfs_create_file("ras_eeprom_reset", S_IWUGO | S_IRUGO, con->dir,
+                               adev, &amdgpu_ras_debugfs_eeprom_ops);
 }
 
 void amdgpu_ras_debugfs_create(struct amdgpu_device *adev,
@@ -1028,10 +1028,8 @@ static void amdgpu_ras_debugfs_remove_all(struct amdgpu_device *adev)
                amdgpu_ras_debugfs_remove(adev, &obj->head);
        }
 
-       debugfs_remove(con->ent);
-       debugfs_remove(con->dir);
+       debugfs_remove_recursive(con->dir);
        con->dir = NULL;
-       con->ent = NULL;
 }
 /* debugfs end */
 
index dd5da3c6327e287e3b190bc06830575d3d7a5ab7..ae386c466c0e438758594bbfa5d3a576f9f235f0 100644 (file)
@@ -317,8 +317,6 @@ struct amdgpu_ras {
        struct list_head head;
        /* debugfs */
        struct dentry *dir;
-       /* debugfs ctrl */
-       struct dentry *ent;
        /* sysfs */
        struct device_attribute features_attr;
        struct bin_attribute badpages_attr;