Commit 42973127 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'for-linus-5.10-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/ubifs

Pull more ubi and ubifs updates from Richard Weinberger:
 "UBI:
   - Correctly use kthread_should_stop in ubi worker

  UBIFS:
   - Fixes for memory leaks while iterating directory entries
   - Fix for a user triggerable error message
   - Fix for a space accounting bug in authenticated mode"

* tag 'for-linus-5.10-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/ubifs:
  ubifs: journal: Make sure to not dirty twice for auth nodes
  ubifs: setflags: Don't show error message when vfs_ioc_setflags_prepare() fails
  ubifs: ubifs_jnl_change_xattr: Remove assertion 'nlink > 0' for host inode
  ubi: check kthread_should_stop() after the setting of task state
  ubifs: dent: Fix some potential memory leaks while iterating entries
  ubifs: xattr: Fix some potential memory leaks while iterating entries
parents a96fd1cc 78c7d49f
...@@ -1639,6 +1639,19 @@ int ubi_thread(void *u) ...@@ -1639,6 +1639,19 @@ int ubi_thread(void *u)
!ubi->thread_enabled || ubi_dbg_is_bgt_disabled(ubi)) { !ubi->thread_enabled || ubi_dbg_is_bgt_disabled(ubi)) {
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
spin_unlock(&ubi->wl_lock); spin_unlock(&ubi->wl_lock);
/*
* Check kthread_should_stop() after we set the task
* state to guarantee that we either see the stop bit
* and exit or the task state is reset to runnable such
* that it's not scheduled out indefinitely and detects
* the stop bit at kthread_should_stop().
*/
if (kthread_should_stop()) {
set_current_state(TASK_RUNNING);
break;
}
schedule(); schedule();
continue; continue;
} }
......
...@@ -1123,6 +1123,7 @@ int dbg_check_dir(struct ubifs_info *c, const struct inode *dir) ...@@ -1123,6 +1123,7 @@ int dbg_check_dir(struct ubifs_info *c, const struct inode *dir)
err = PTR_ERR(dent); err = PTR_ERR(dent);
if (err == -ENOENT) if (err == -ENOENT)
break; break;
kfree(pdent);
return err; return err;
} }
......
...@@ -134,7 +134,6 @@ static int setflags(struct inode *inode, int flags) ...@@ -134,7 +134,6 @@ static int setflags(struct inode *inode, int flags)
return err; return err;
out_unlock: out_unlock:
ubifs_err(c, "can't modify inode %lu attributes", inode->i_ino);
mutex_unlock(&ui->ui_mutex); mutex_unlock(&ui->ui_mutex);
ubifs_release_budget(c, &req); ubifs_release_budget(c, &req);
return err; return err;
......
...@@ -894,6 +894,7 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode) ...@@ -894,6 +894,7 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode)
if (err == -ENOENT) if (err == -ENOENT)
break; break;
kfree(pxent);
goto out_release; goto out_release;
} }
...@@ -906,6 +907,7 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode) ...@@ -906,6 +907,7 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode)
ubifs_err(c, "dead directory entry '%s', error %d", ubifs_err(c, "dead directory entry '%s', error %d",
xent->name, err); xent->name, err);
ubifs_ro_mode(c, err); ubifs_ro_mode(c, err);
kfree(pxent);
kfree(xent); kfree(xent);
goto out_release; goto out_release;
} }
...@@ -936,8 +938,6 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode) ...@@ -936,8 +938,6 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode)
inode->i_ino); inode->i_ino);
release_head(c, BASEHD); release_head(c, BASEHD);
ubifs_add_auth_dirt(c, lnum);
if (last_reference) { if (last_reference) {
err = ubifs_tnc_remove_ino(c, inode->i_ino); err = ubifs_tnc_remove_ino(c, inode->i_ino);
if (err) if (err)
...@@ -947,6 +947,8 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode) ...@@ -947,6 +947,8 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode)
} else { } else {
union ubifs_key key; union ubifs_key key;
ubifs_add_auth_dirt(c, lnum);
ino_key_init(c, &key, inode->i_ino); ino_key_init(c, &key, inode->i_ino);
err = ubifs_tnc_add(c, &key, lnum, offs, ilen, hash); err = ubifs_tnc_add(c, &key, lnum, offs, ilen, hash);
} }
...@@ -1798,7 +1800,6 @@ int ubifs_jnl_change_xattr(struct ubifs_info *c, const struct inode *inode, ...@@ -1798,7 +1800,6 @@ int ubifs_jnl_change_xattr(struct ubifs_info *c, const struct inode *inode,
u8 hash[UBIFS_HASH_ARR_SZ]; u8 hash[UBIFS_HASH_ARR_SZ];
dbg_jnl("ino %lu, ino %lu", host->i_ino, inode->i_ino); dbg_jnl("ino %lu, ino %lu", host->i_ino, inode->i_ino);
ubifs_assert(c, host->i_nlink > 0);
ubifs_assert(c, inode->i_nlink > 0); ubifs_assert(c, inode->i_nlink > 0);
ubifs_assert(c, mutex_is_locked(&host_ui->ui_mutex)); ubifs_assert(c, mutex_is_locked(&host_ui->ui_mutex));
......
...@@ -173,6 +173,7 @@ int ubifs_add_orphan(struct ubifs_info *c, ino_t inum) ...@@ -173,6 +173,7 @@ int ubifs_add_orphan(struct ubifs_info *c, ino_t inum)
err = PTR_ERR(xent); err = PTR_ERR(xent);
if (err == -ENOENT) if (err == -ENOENT)
break; break;
kfree(pxent);
return err; return err;
} }
...@@ -182,6 +183,7 @@ int ubifs_add_orphan(struct ubifs_info *c, ino_t inum) ...@@ -182,6 +183,7 @@ int ubifs_add_orphan(struct ubifs_info *c, ino_t inum)
xattr_orphan = orphan_add(c, xattr_inum, orphan); xattr_orphan = orphan_add(c, xattr_inum, orphan);
if (IS_ERR(xattr_orphan)) { if (IS_ERR(xattr_orphan)) {
kfree(pxent);
kfree(xent); kfree(xent);
return PTR_ERR(xattr_orphan); return PTR_ERR(xattr_orphan);
} }
......
...@@ -2884,6 +2884,7 @@ int ubifs_tnc_remove_ino(struct ubifs_info *c, ino_t inum) ...@@ -2884,6 +2884,7 @@ int ubifs_tnc_remove_ino(struct ubifs_info *c, ino_t inum)
err = PTR_ERR(xent); err = PTR_ERR(xent);
if (err == -ENOENT) if (err == -ENOENT)
break; break;
kfree(pxent);
return err; return err;
} }
...@@ -2897,6 +2898,7 @@ int ubifs_tnc_remove_ino(struct ubifs_info *c, ino_t inum) ...@@ -2897,6 +2898,7 @@ int ubifs_tnc_remove_ino(struct ubifs_info *c, ino_t inum)
fname_len(&nm) = le16_to_cpu(xent->nlen); fname_len(&nm) = le16_to_cpu(xent->nlen);
err = ubifs_tnc_remove_nm(c, &key1, &nm); err = ubifs_tnc_remove_nm(c, &key1, &nm);
if (err) { if (err) {
kfree(pxent);
kfree(xent); kfree(xent);
return err; return err;
} }
...@@ -2905,6 +2907,7 @@ int ubifs_tnc_remove_ino(struct ubifs_info *c, ino_t inum) ...@@ -2905,6 +2907,7 @@ int ubifs_tnc_remove_ino(struct ubifs_info *c, ino_t inum)
highest_ino_key(c, &key2, xattr_inum); highest_ino_key(c, &key2, xattr_inum);
err = ubifs_tnc_remove_range(c, &key1, &key2); err = ubifs_tnc_remove_range(c, &key1, &key2);
if (err) { if (err) {
kfree(pxent);
kfree(xent); kfree(xent);
return err; return err;
} }
......
...@@ -522,6 +522,7 @@ int ubifs_purge_xattrs(struct inode *host) ...@@ -522,6 +522,7 @@ int ubifs_purge_xattrs(struct inode *host)
xent->name, err); xent->name, err);
ubifs_ro_mode(c, err); ubifs_ro_mode(c, err);
kfree(pxent); kfree(pxent);
kfree(xent);
return err; return err;
} }
...@@ -531,6 +532,7 @@ int ubifs_purge_xattrs(struct inode *host) ...@@ -531,6 +532,7 @@ int ubifs_purge_xattrs(struct inode *host)
err = remove_xattr(c, host, xino, &nm); err = remove_xattr(c, host, xino, &nm);
if (err) { if (err) {
kfree(pxent); kfree(pxent);
kfree(xent);
iput(xino); iput(xino);
ubifs_err(c, "cannot remove xattr, error %d", err); ubifs_err(c, "cannot remove xattr, error %d", err);
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment