From fecd4406b328292a9da91db4cb42f6ba6b54e33b Mon Sep 17 00:00:00 2001 From: Pavel Snajdr Date: Wed, 9 Oct 2024 01:53:17 +0200 Subject: [PATCH] Linux: zpl_tmpfile: ensure ACL init succeeds before d_tmpfile Inode should be linked to dentry and hashed only after both zpl_xattr_security_init and zpl_init_acl were successful, which apparently isn't always true for example when memory is tight. Signed-off-by: Pavel Snajdr --- module/os/linux/zfs/zpl_inode.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/module/os/linux/zfs/zpl_inode.c b/module/os/linux/zfs/zpl_inode.c index c4b5087ca5e7..d1b249386fe4 100644 --- a/module/os/linux/zfs/zpl_inode.c +++ b/module/os/linux/zfs/zpl_inode.c @@ -317,19 +317,19 @@ zpl_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode) /* d_tmpfile will do drop_nlink, so we should set it first */ set_nlink(ip, 1); #ifndef HAVE_TMPFILE_DENTRY - d_tmpfile(file, ip); - error = zpl_xattr_security_init(ip, dir, &file->f_path.dentry->d_name); + if (error == 0) + error = zpl_init_acl(ip, dir); + if (error == 0) + d_tmpfile(file, ip); + error = finish_open_simple(file, error); #else - d_tmpfile(dentry, ip); - error = zpl_xattr_security_init(ip, dir, &dentry->d_name); -#endif if (error == 0) error = zpl_init_acl(ip, dir); -#ifndef HAVE_TMPFILE_DENTRY - error = finish_open_simple(file, error); + if (error == 0) + d_tmpfile(dentry, ip); #endif /* * don't need to handle error here, file is already in