]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
functionfs, gadgetfs: use simple_recursive_removal()
authorAl Viro <viro@zeniv.linux.org.uk>
Mon, 10 Mar 2025 04:45:20 +0000 (00:45 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 3 Jul 2025 02:36:52 +0000 (22:36 -0400)
usual mount leaks if something had been bound on top of disappearing
files there.

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
drivers/usb/gadget/function/f_fs.c
drivers/usb/gadget/legacy/inode.c

index 2dea9e42a0f86b4ba9db52de411b849b88ce7569..ea5f0af1e8d2072432487f1a59ff28cee4c88c10 100644 (file)
@@ -2369,8 +2369,7 @@ static void ffs_epfiles_destroy(struct ffs_epfile *epfiles, unsigned count)
        for (; count; --count, ++epfile) {
                BUG_ON(mutex_is_locked(&epfile->mutex));
                if (epfile->dentry) {
-                       d_delete(epfile->dentry);
-                       dput(epfile->dentry);
+                       simple_recursive_removal(epfile->dentry, NULL);
                        epfile->dentry = NULL;
                }
        }
index fcce84a726f2cfeb47acfc7620203b29b1e28815..b51e132b0cd2a7410450c998878dff911b1f96fe 100644 (file)
@@ -1561,7 +1561,6 @@ static void destroy_ep_files (struct dev_data *dev)
        spin_lock_irq (&dev->lock);
        while (!list_empty(&dev->epfiles)) {
                struct ep_data  *ep;
-               struct inode    *parent;
                struct dentry   *dentry;
 
                /* break link to FS */
@@ -1571,7 +1570,6 @@ static void destroy_ep_files (struct dev_data *dev)
 
                dentry = ep->dentry;
                ep->dentry = NULL;
-               parent = d_inode(dentry->d_parent);
 
                /* break link to controller */
                mutex_lock(&ep->lock);
@@ -1586,10 +1584,7 @@ static void destroy_ep_files (struct dev_data *dev)
                put_ep (ep);
 
                /* break link to dcache */
-               inode_lock(parent);
-               d_delete (dentry);
-               dput (dentry);
-               inode_unlock(parent);
+               simple_recursive_removal(dentry, NULL);
 
                spin_lock_irq (&dev->lock);
        }