Skip to content

Commit 4297312

Browse files
committed
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
2 parents a96fd1c + 78c7d49 commit 4297312

7 files changed

Lines changed: 25 additions & 4 deletions

File tree

drivers/mtd/ubi/wl.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,6 +1639,19 @@ int ubi_thread(void *u)
16391639
!ubi->thread_enabled || ubi_dbg_is_bgt_disabled(ubi)) {
16401640
set_current_state(TASK_INTERRUPTIBLE);
16411641
spin_unlock(&ubi->wl_lock);
1642+
1643+
/*
1644+
* Check kthread_should_stop() after we set the task
1645+
* state to guarantee that we either see the stop bit
1646+
* and exit or the task state is reset to runnable such
1647+
* that it's not scheduled out indefinitely and detects
1648+
* the stop bit at kthread_should_stop().
1649+
*/
1650+
if (kthread_should_stop()) {
1651+
set_current_state(TASK_RUNNING);
1652+
break;
1653+
}
1654+
16421655
schedule();
16431656
continue;
16441657
}

fs/ubifs/debug.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,7 @@ int dbg_check_dir(struct ubifs_info *c, const struct inode *dir)
11231123
err = PTR_ERR(dent);
11241124
if (err == -ENOENT)
11251125
break;
1126+
kfree(pdent);
11261127
return err;
11271128
}
11281129

fs/ubifs/ioctl.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ static int setflags(struct inode *inode, int flags)
134134
return err;
135135

136136
out_unlock:
137-
ubifs_err(c, "can't modify inode %lu attributes", inode->i_ino);
138137
mutex_unlock(&ui->ui_mutex);
139138
ubifs_release_budget(c, &req);
140139
return err;

fs/ubifs/journal.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,7 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode)
894894
if (err == -ENOENT)
895895
break;
896896

897+
kfree(pxent);
897898
goto out_release;
898899
}
899900

@@ -906,6 +907,7 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode)
906907
ubifs_err(c, "dead directory entry '%s', error %d",
907908
xent->name, err);
908909
ubifs_ro_mode(c, err);
910+
kfree(pxent);
909911
kfree(xent);
910912
goto out_release;
911913
}
@@ -936,8 +938,6 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode)
936938
inode->i_ino);
937939
release_head(c, BASEHD);
938940

939-
ubifs_add_auth_dirt(c, lnum);
940-
941941
if (last_reference) {
942942
err = ubifs_tnc_remove_ino(c, inode->i_ino);
943943
if (err)
@@ -947,6 +947,8 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode)
947947
} else {
948948
union ubifs_key key;
949949

950+
ubifs_add_auth_dirt(c, lnum);
951+
950952
ino_key_init(c, &key, inode->i_ino);
951953
err = ubifs_tnc_add(c, &key, lnum, offs, ilen, hash);
952954
}
@@ -1798,7 +1800,6 @@ int ubifs_jnl_change_xattr(struct ubifs_info *c, const struct inode *inode,
17981800
u8 hash[UBIFS_HASH_ARR_SZ];
17991801

18001802
dbg_jnl("ino %lu, ino %lu", host->i_ino, inode->i_ino);
1801-
ubifs_assert(c, host->i_nlink > 0);
18021803
ubifs_assert(c, inode->i_nlink > 0);
18031804
ubifs_assert(c, mutex_is_locked(&host_ui->ui_mutex));
18041805

fs/ubifs/orphan.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ int ubifs_add_orphan(struct ubifs_info *c, ino_t inum)
173173
err = PTR_ERR(xent);
174174
if (err == -ENOENT)
175175
break;
176+
kfree(pxent);
176177
return err;
177178
}
178179

@@ -182,6 +183,7 @@ int ubifs_add_orphan(struct ubifs_info *c, ino_t inum)
182183

183184
xattr_orphan = orphan_add(c, xattr_inum, orphan);
184185
if (IS_ERR(xattr_orphan)) {
186+
kfree(pxent);
185187
kfree(xent);
186188
return PTR_ERR(xattr_orphan);
187189
}

fs/ubifs/tnc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2884,6 +2884,7 @@ int ubifs_tnc_remove_ino(struct ubifs_info *c, ino_t inum)
28842884
err = PTR_ERR(xent);
28852885
if (err == -ENOENT)
28862886
break;
2887+
kfree(pxent);
28872888
return err;
28882889
}
28892890

@@ -2897,6 +2898,7 @@ int ubifs_tnc_remove_ino(struct ubifs_info *c, ino_t inum)
28972898
fname_len(&nm) = le16_to_cpu(xent->nlen);
28982899
err = ubifs_tnc_remove_nm(c, &key1, &nm);
28992900
if (err) {
2901+
kfree(pxent);
29002902
kfree(xent);
29012903
return err;
29022904
}
@@ -2905,6 +2907,7 @@ int ubifs_tnc_remove_ino(struct ubifs_info *c, ino_t inum)
29052907
highest_ino_key(c, &key2, xattr_inum);
29062908
err = ubifs_tnc_remove_range(c, &key1, &key2);
29072909
if (err) {
2910+
kfree(pxent);
29082911
kfree(xent);
29092912
return err;
29102913
}

fs/ubifs/xattr.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ int ubifs_purge_xattrs(struct inode *host)
522522
xent->name, err);
523523
ubifs_ro_mode(c, err);
524524
kfree(pxent);
525+
kfree(xent);
525526
return err;
526527
}
527528

@@ -531,6 +532,7 @@ int ubifs_purge_xattrs(struct inode *host)
531532
err = remove_xattr(c, host, xino, &nm);
532533
if (err) {
533534
kfree(pxent);
535+
kfree(xent);
534536
iput(xino);
535537
ubifs_err(c, "cannot remove xattr, error %d", err);
536538
return err;

0 commit comments

Comments
 (0)