diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c index 36624990b577..70a5cb977ed0 100644 --- a/mm/damon/dbgfs.c +++ b/mm/damon/dbgfs.c @@ -376,6 +376,9 @@ static int dbgfs_mk_context(char *name) return -ENOENT; new_dir = debugfs_create_dir(name, root); + /* Below check is required for a potential duplicated name case */ + if (IS_ERR(new_dir)) + return PTR_ERR(new_dir); dbgfs_dirs[dbgfs_nr_ctxs] = new_dir; new_ctx = dbgfs_new_ctx();