[PATCH] DAMON dbgfs_mk_context() error handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx

---

--- 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();


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux