diff mbox series

[3/4] btrfs: drop path before copying rootrefs to userspace

Message ID 77cf63bc66bdccb723c8a6837feb54827cc15432.1668056532.git.anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series btrfs: drop path before copying to userspace | expand

Commit Message

Anand Jain Nov. 10, 2022, 6:06 a.m. UTC
btrfs_ioctl_get_subvol_rootref() frees the search path after the userspace
copy from the temp buffer %rootrefs, which can lead to a lock splat warning.

Fix this by freeing the path before we copy it to userspace.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 707b2321c8db..ec310868591c 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2303,6 +2303,7 @@  static int btrfs_ioctl_get_subvol_rootref(struct btrfs_root *root,
 	}
 
 out:
+	btrfs_free_path(path);
 	if (!ret || ret == -EOVERFLOW) {
 		rootrefs->num_items = found;
 		/* update min_treeid for next search */
@@ -2314,7 +2315,6 @@  static int btrfs_ioctl_get_subvol_rootref(struct btrfs_root *root,
 	}
 
 	kfree(rootrefs);
-	btrfs_free_path(path);
 
 	return ret;
 }