hulk inclusion category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/21064 -------------------------------- debugfs_read_file_cpumask() takes a reference on the dentry with debugfs_file_get() and drops it at the debugfs_put label. When the kmalloc() of the temporary buffer fails it jumps to kfree instead, which skips debugfs_file_put(), so the reference stays taken. The file system is then held open and cannot be unmounted. Jump to the debugfs_put label, which drops the dentry reference and, after the same change, frees the buffer. Remove the now unused kfree label. Reached only when the buffer allocation fails, which needs memory pressure. Fixes: 0eff08a2e543 ("debugfs: Add helpers for creating cpumask entries in debugfs") Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> --- fs/debugfs/file.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index 319d4261d467..2d1276300728 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -1021,7 +1021,7 @@ static ssize_t debugfs_read_file_cpumask(struct file *file, kernel_buf = kmalloc(PAGE_SIZE, GFP_KERNEL); if (!kernel_buf) { ret = -ENOMEM; - goto kfree; + goto debugfs_put; } cpumask = (struct cpumask *)file->private_data; @@ -1036,7 +1036,6 @@ static ssize_t debugfs_read_file_cpumask(struct file *file, debugfs_put: debugfs_file_put(dentry); -kfree: kfree(kernel_buf); return ret; } -- 2.34.1