Skip to content

Commit 5ff93ab

Browse files
committed
Merge tag 'upstream-4.9-rc2' of git://git.infradead.org/linux-ubifs
Pull UBI[FS] fixes from Richard Weinberger: "This contains fixes for issues in both UBI and UBIFS: - Fallout from the merge window, refactoring UBI code introduced some issues. - Fixes for an UBIFS readdir bug which can cause getdents() to busy loop for ever and a bug in the UBIFS xattr code" * tag 'upstream-4.9-rc2' of git://git.infradead.org/linux-ubifs: ubifs: Abort readdir upon error UBI: Fix crash in try_recover_peb() ubi: fix swapped arguments to call to ubi_alloc_aeb ubifs: Fix xattr_names length in exit paths ubifs: Rename ubifs_rename2
2 parents c761923 + c83ed4c commit 5ff93ab

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

drivers/mtd/ubi/eba.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,7 @@ static int try_recover_peb(struct ubi_volume *vol, int pnum, int lnum,
741741
goto out_put;
742742
}
743743

744+
vid_hdr = ubi_get_vid_hdr(vidb);
744745
ubi_assert(vid_hdr->vol_type == UBI_VID_DYNAMIC);
745746

746747
mutex_lock(&ubi->buf_mutex);

drivers/mtd/ubi/fastmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ static int update_vol(struct ubi_device *ubi, struct ubi_attach_info *ai,
287287

288288
/* new_aeb is newer */
289289
if (cmp_res & 1) {
290-
victim = ubi_alloc_aeb(ai, aeb->ec, aeb->pnum);
290+
victim = ubi_alloc_aeb(ai, aeb->pnum, aeb->ec);
291291
if (!victim)
292292
return -ENOMEM;
293293

fs/ubifs/dir.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ static unsigned int vfs_dent_type(uint8_t type)
439439
*/
440440
static int ubifs_readdir(struct file *file, struct dir_context *ctx)
441441
{
442-
int err;
442+
int err = 0;
443443
struct qstr nm;
444444
union ubifs_key key;
445445
struct ubifs_dent_node *dent;
@@ -541,14 +541,12 @@ static int ubifs_readdir(struct file *file, struct dir_context *ctx)
541541
kfree(file->private_data);
542542
file->private_data = NULL;
543543

544-
if (err != -ENOENT) {
544+
if (err != -ENOENT)
545545
ubifs_err(c, "cannot find next direntry, error %d", err);
546-
return err;
547-
}
548546

549547
/* 2 is a special value indicating that there are no more direntries */
550548
ctx->pos = 2;
551-
return 0;
549+
return err;
552550
}
553551

554552
/* Free saved readdir() state when the directory is closed */
@@ -1060,9 +1058,9 @@ static void unlock_4_inodes(struct inode *inode1, struct inode *inode2,
10601058
mutex_unlock(&ubifs_inode(inode1)->ui_mutex);
10611059
}
10621060

1063-
static int ubifs_rename(struct inode *old_dir, struct dentry *old_dentry,
1064-
struct inode *new_dir, struct dentry *new_dentry,
1065-
unsigned int flags)
1061+
static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
1062+
struct inode *new_dir, struct dentry *new_dentry,
1063+
unsigned int flags)
10661064
{
10671065
struct ubifs_info *c = old_dir->i_sb->s_fs_info;
10681066
struct inode *old_inode = d_inode(old_dentry);
@@ -1323,7 +1321,7 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
13231321
return err;
13241322
}
13251323

1326-
static int ubifs_rename2(struct inode *old_dir, struct dentry *old_dentry,
1324+
static int ubifs_rename(struct inode *old_dir, struct dentry *old_dentry,
13271325
struct inode *new_dir, struct dentry *new_dentry,
13281326
unsigned int flags)
13291327
{
@@ -1336,7 +1334,7 @@ static int ubifs_rename2(struct inode *old_dir, struct dentry *old_dentry,
13361334
if (flags & RENAME_EXCHANGE)
13371335
return ubifs_xrename(old_dir, old_dentry, new_dir, new_dentry);
13381336

1339-
return ubifs_rename(old_dir, old_dentry, new_dir, new_dentry, flags);
1337+
return do_rename(old_dir, old_dentry, new_dir, new_dentry, flags);
13401338
}
13411339

13421340
int ubifs_getattr(struct vfsmount *mnt, struct dentry *dentry,
@@ -1387,7 +1385,7 @@ const struct inode_operations ubifs_dir_inode_operations = {
13871385
.mkdir = ubifs_mkdir,
13881386
.rmdir = ubifs_rmdir,
13891387
.mknod = ubifs_mknod,
1390-
.rename = ubifs_rename2,
1388+
.rename = ubifs_rename,
13911389
.setattr = ubifs_setattr,
13921390
.getattr = ubifs_getattr,
13931391
.listxattr = ubifs_listxattr,

fs/ubifs/xattr.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ static int create_xattr(struct ubifs_info *c, struct inode *host,
172172
host_ui->xattr_cnt -= 1;
173173
host_ui->xattr_size -= CALC_DENT_SIZE(nm->len);
174174
host_ui->xattr_size -= CALC_XATTR_BYTES(size);
175+
host_ui->xattr_names -= nm->len;
175176
mutex_unlock(&host_ui->ui_mutex);
176177
out_free:
177178
make_bad_inode(inode);
@@ -478,6 +479,7 @@ static int remove_xattr(struct ubifs_info *c, struct inode *host,
478479
host_ui->xattr_cnt += 1;
479480
host_ui->xattr_size += CALC_DENT_SIZE(nm->len);
480481
host_ui->xattr_size += CALC_XATTR_BYTES(ui->data_len);
482+
host_ui->xattr_names += nm->len;
481483
mutex_unlock(&host_ui->ui_mutex);
482484
ubifs_release_budget(c, &req);
483485
make_bad_inode(inode);

0 commit comments

Comments
 (0)