hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/mm/damon/dbgfs.c
....@@ -785,6 +785,7 @@
785785 static int dbgfs_rm_context(char *name)
786786 {
787787 struct dentry *root, *dir, **new_dirs;
788
+ struct inode *inode;
788789 struct damon_ctx **new_ctxs;
789790 int i, j;
790791 int ret = 0;
....@@ -800,6 +801,12 @@
800801 if (!dir)
801802 return -ENOENT;
802803
804
+ inode = d_inode(dir);
805
+ if (!S_ISDIR(inode->i_mode)) {
806
+ ret = -EINVAL;
807
+ goto out_dput;
808
+ }
809
+
803810 new_dirs = kmalloc_array(dbgfs_nr_ctxs - 1, sizeof(*dbgfs_dirs),
804811 GFP_KERNEL);
805812 if (!new_dirs) {