ubifs: Fix xattr_names length in exit paths
authorRichard Weinberger <richard@nod.at>
Tue, 20 Sep 2016 08:08:30 +0000 (10:08 +0200)
committerSasha Levin <alexander.levin@verizon.com>
Thu, 24 Nov 2016 02:31:24 +0000 (21:31 -0500)
[ Upstream commit 843741c5778398ea67055067f4cc65ae6c80ca0e ]

When the operation fails we also have to undo the changes
we made to ->xattr_names. Otherwise listxattr() will report
wrong lengths.

Cc: stable@vger.kernel.org
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
fs/ubifs/xattr.c

index 5e0a63b1b0d54a24d407c08cf1f3fef25008e0f9..ce6c0d4aa48dba99138689c15b5b5877e81fc728 100644 (file)
@@ -167,6 +167,7 @@ out_cancel:
        host_ui->xattr_cnt -= 1;
        host_ui->xattr_size -= CALC_DENT_SIZE(nm->len);
        host_ui->xattr_size -= CALC_XATTR_BYTES(size);
+       host_ui->xattr_names -= nm->len;
        mutex_unlock(&host_ui->ui_mutex);
 out_free:
        make_bad_inode(inode);
@@ -514,6 +515,7 @@ out_cancel:
        host_ui->xattr_cnt += 1;
        host_ui->xattr_size += CALC_DENT_SIZE(nm->len);
        host_ui->xattr_size += CALC_XATTR_BYTES(ui->data_len);
+       host_ui->xattr_names += nm->len;
        mutex_unlock(&host_ui->ui_mutex);
        ubifs_release_budget(c, &req);
        make_bad_inode(inode);