diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 21d2e3df1b4fc60923a66c8d13c88665c42f53b5..5dc2fd843ae37727609a9e4aa5950478ea5280c9 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -259,6 +259,8 @@ int btrfs_fileattr_set(struct user_namespace *mnt_userns,
 	if (!fa->flags_valid) {
 		/* 1 item for the inode */
 		trans = btrfs_start_transaction(root, 1);
+		if (IS_ERR(trans))
+			return PTR_ERR(trans);
 		goto update_flags;
 	}