From: Subodh Nijsure <[email protected]>

Cc: linux-stable <[email protected]>
Signed-off-by: Subodh Nijsure <[email protected]>
Signed-off-by: Marc Kleine-Budde <[email protected]>
---
 fs/ubifs/journal.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
index afaad07..b96718a 100644
--- a/fs/ubifs/journal.c
+++ b/fs/ubifs/journal.c
@@ -553,7 +553,8 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct 
inode *dir,
 
        dbg_jnl("ino %lu, dent '%.*s', data len %d in dir ino %lu",
                inode->i_ino, nm->len, nm->name, ui->data_len, dir->i_ino);
-       ubifs_assert(dir_ui->data_len == 0);
+       if (!xent)
+               ubifs_assert(dir_ui->data_len == 0);
        ubifs_assert(mutex_is_locked(&dir_ui->ui_mutex));
 
        dlen = UBIFS_DENT_NODE_SZ + nm->len + 1;
@@ -572,7 +573,12 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct 
inode *dir,
 
        aligned_dlen = ALIGN(dlen, 8);
        aligned_ilen = ALIGN(ilen, 8);
-       len = aligned_dlen + aligned_ilen + UBIFS_INO_NODE_SZ;
+       /*
+        * Make sure to account for dir_ui+data_len in length
+        * calculation in case there is extended attribute.
+        */
+       len = aligned_dlen + aligned_ilen +
+             UBIFS_INO_NODE_SZ + dir_ui->data_len;
        dent = kmalloc(len, GFP_NOFS);
        if (!dent)
                return -ENOMEM;
@@ -649,7 +655,8 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct 
inode *dir,
 
        ino_key_init(c, &ino_key, dir->i_ino);
        ino_offs += aligned_ilen;
-       err = ubifs_tnc_add(c, &ino_key, lnum, ino_offs, UBIFS_INO_NODE_SZ);
+       err = ubifs_tnc_add(c, &ino_key, lnum, ino_offs,
+                           UBIFS_INO_NODE_SZ + dir_ui->data_len);
        if (err)
                goto out_ro;
 
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to