@@ -44,6 +44,7 @@ static unsigned ttm_glob_use_count;
struct ttm_global ttm_glob;
EXPORT_SYMBOL(ttm_glob);
+/* Do not deference this pointer as it will contain ERR_PTR on error. */
struct dentry *ttm_debugfs_root;
static void ttm_global_release(void)
@@ -77,9 +78,6 @@ static int ttm_global_init(void)
si_meminfo(&si);
ttm_debugfs_root = debugfs_create_dir("ttm", NULL);
- if (IS_ERR(ttm_debugfs_root)) {
- ttm_debugfs_root = NULL;
- }
/* Limit the number of pages in the pool to about 50% of the total
* system memory.
@@ -108,8 +106,7 @@ static int ttm_global_init(void)
debugfs_create_atomic_t("buffer_objects", 0444, ttm_debugfs_root,
&glob->bo_count);
out:
- if (ret && ttm_debugfs_root)
- debugfs_remove(ttm_debugfs_root);
+ debugfs_remove(ttm_debugfs_root);
if (ret)
--ttm_glob_use_count;
mutex_unlock(&ttm_global_mutex);
For debugfs directory, it is recommended to save the result and pass over to next debugfs API for creating debugfs files/directories. Error conditions are handled by debugfs APIs. CC: Christian Koenig <christian.koenig@amd.com> CC: Huang Rui <ray.huang@amd.com> CC: David Airlie <airlied@linux.ie> CC: Daniel Vetter <daniel@ffwll.ch> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com> --- drivers/gpu/drm/ttm/ttm_device.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)