Skip to content

Commit 112cedc

Browse files
ecsvgregkh
authored andcommitted
debugfs: Return error during {full/open}_proxy_open() on rmmod
If a kernel module gets unloaded then it printed report about a leak before commit 275678e ("debugfs: Check module state before warning in {full/open}_proxy_open()"). An additional check was added in this commit to avoid this printing. But it was forgotten that the function must return an error in this case because it was not actually opened. As result, the systems started to crash or to hang when a module was unloaded while something was trying to open a file. Fixes: 275678e ("debugfs: Check module state before warning in {full/open}_proxy_open()") Cc: Taehee Yoo <[email protected]> Reported-by: Mário Lopes <[email protected]> Signed-off-by: Sven Eckelmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent fac58b4 commit 112cedc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

fs/debugfs/file.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,10 @@ static int open_proxy_open(struct inode *inode, struct file *filp)
179179
if (!fops_get(real_fops)) {
180180
#ifdef CONFIG_MODULES
181181
if (real_fops->owner &&
182-
real_fops->owner->state == MODULE_STATE_GOING)
182+
real_fops->owner->state == MODULE_STATE_GOING) {
183+
r = -ENXIO;
183184
goto out;
185+
}
184186
#endif
185187

186188
/* Huh? Module did not clean up after itself at exit? */
@@ -314,8 +316,10 @@ static int full_proxy_open(struct inode *inode, struct file *filp)
314316
if (!fops_get(real_fops)) {
315317
#ifdef CONFIG_MODULES
316318
if (real_fops->owner &&
317-
real_fops->owner->state == MODULE_STATE_GOING)
319+
real_fops->owner->state == MODULE_STATE_GOING) {
320+
r = -ENXIO;
318321
goto out;
322+
}
319323
#endif
320324

321325
/* Huh? Module did not cleanup after itself at exit? */

0 commit comments

Comments
 (0)