diff mbox series

DAMON dbgfs_mk_context() error handling

Message ID DM6PR11MB39782C920CFA9E25594EF9D59C679@DM6PR11MB3978.namprd11.prod.outlook.com (mailing list archive)
State New
Headers show
Series DAMON dbgfs_mk_context() error handling | expand

Commit Message

Pulavarty, Badari Aug. 12, 2022, 5:57 p.m. UTC
damon dbgfs_mk_context() does not handle error from debugfs_create_dir() correctly.

For example, if one tries to create a context with existing name, debugfs_create_dir() fails
with -EEXIST, but dbgfs_mk_context() assumes the call is successful and adds another entry - which
will cause failures when try to enable the monitor.

Test case:

echo "off" >  /sys/kernel/debug/damon/monitor_on
echo "abc" > /sys/kernel/debug/damon/mk_context
echo "abc" > /sys/kernel/debug/damon/mk_context
echo <pid> > /sys/kernel/debug/damon/target_ids
echo "on" > /sys/kernel/debug/damon/monitor_on  <<< fails to enable monitor


Signed-off-by: Badari Pulavarty badari.pulavarty@intel.com<mailto:badari.pulavarty@intel.com>
---
diff mbox series

Patch

--- orig/mm/damon/dbgfs.c       2022-08-05 13:35:54.416831666 -0400
+++ new/mm/damon/dbgfs.c        2022-08-05 13:44:25.121849930 -0400
@@ -721,6 +721,9 @@  static int dbgfs_mk_context(char *name)
                return -ENOENT;

        new_dir = debugfs_create_dir(name, root);
+       if (IS_ERR(new_dir)) {
+               return PTR_ERR(new_dir);
+       }
        dbgfs_dirs[dbgfs_nr_ctxs] = new_dir;

        new_ctx = dbgfs_new_ctx();