Skip to content

Commit 9ea33c4

Browse files
committed
Merge tag 'upstream-4.11-rc7' of git://git.infradead.org/linux-ubifs
Pull UBI/UBIFS fixes from Richard Weinberger: "This contains fixes for issues in both UBI and UBIFS: - more O_TMPFILE fallout - RENAME_WHITEOUT regression due to a mis-merge - memory leak in ubifs_mknod() - power-cut problem in UBI's update volume feature" * tag 'upstream-4.11-rc7' of git://git.infradead.org/linux-ubifs: ubifs: Fix O_TMPFILE corner case in ubifs_link() ubifs: Fix RENAME_WHITEOUT support ubifs: Fix debug messages for an invalid filename in ubifs_dump_inode ubifs: Fix debug messages for an invalid filename in ubifs_dump_node ubifs: Remove filename from debug messages in ubifs_readdir ubifs: Fix memory leak in error path in ubifs_mknod ubi/upd: Always flush after prepared for an update
2 parents e0f4e01 + 32fe905 commit 9ea33c4

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

drivers/mtd/ubi/upd.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,11 @@ int ubi_start_update(struct ubi_device *ubi, struct ubi_volume *vol,
148148
return err;
149149
}
150150

151-
if (bytes == 0) {
152-
err = ubi_wl_flush(ubi, UBI_ALL, UBI_ALL);
153-
if (err)
154-
return err;
151+
err = ubi_wl_flush(ubi, UBI_ALL, UBI_ALL);
152+
if (err)
153+
return err;
155154

155+
if (bytes == 0) {
156156
err = clear_update_marker(ubi, vol, 0);
157157
if (err)
158158
return err;

fs/ubifs/debug.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <linux/math64.h>
3333
#include <linux/uaccess.h>
3434
#include <linux/random.h>
35+
#include <linux/ctype.h>
3536
#include "ubifs.h"
3637

3738
static DEFINE_SPINLOCK(dbg_lock);
@@ -286,8 +287,10 @@ void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode)
286287
break;
287288
}
288289

289-
pr_err("\t%d: %s (%s)\n",
290-
count++, dent->name, get_dent_type(dent->type));
290+
pr_err("\t%d: inode %llu, type %s, len %d\n",
291+
count++, (unsigned long long) le64_to_cpu(dent->inum),
292+
get_dent_type(dent->type),
293+
le16_to_cpu(dent->nlen));
291294

292295
fname_name(&nm) = dent->name;
293296
fname_len(&nm) = le16_to_cpu(dent->nlen);
@@ -464,7 +467,8 @@ void ubifs_dump_node(const struct ubifs_info *c, const void *node)
464467
pr_err("(bad name length, not printing, bad or corrupted node)");
465468
else {
466469
for (i = 0; i < nlen && dent->name[i]; i++)
467-
pr_cont("%c", dent->name[i]);
470+
pr_cont("%c", isprint(dent->name[i]) ?
471+
dent->name[i] : '?');
468472
}
469473
pr_cont("\n");
470474

fs/ubifs/dir.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,8 @@ static int ubifs_readdir(struct file *file, struct dir_context *ctx)
606606
}
607607

608608
while (1) {
609-
dbg_gen("feed '%s', ino %llu, new f_pos %#x",
610-
dent->name, (unsigned long long)le64_to_cpu(dent->inum),
609+
dbg_gen("ino %llu, new f_pos %#x",
610+
(unsigned long long)le64_to_cpu(dent->inum),
611611
key_hash_flash(c, &dent->key));
612612
ubifs_assert(le64_to_cpu(dent->ch.sqnum) >
613613
ubifs_inode(dir)->creat_sqnum);
@@ -748,6 +748,11 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir,
748748
goto out_fname;
749749

750750
lock_2_inodes(dir, inode);
751+
752+
/* Handle O_TMPFILE corner case, it is allowed to link a O_TMPFILE. */
753+
if (inode->i_nlink == 0)
754+
ubifs_delete_orphan(c, inode->i_ino);
755+
751756
inc_nlink(inode);
752757
ihold(inode);
753758
inode->i_ctime = ubifs_current_time(inode);
@@ -768,6 +773,8 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir,
768773
dir->i_size -= sz_change;
769774
dir_ui->ui_size = dir->i_size;
770775
drop_nlink(inode);
776+
if (inode->i_nlink == 0)
777+
ubifs_add_orphan(c, inode->i_ino);
771778
unlock_2_inodes(dir, inode);
772779
ubifs_release_budget(c, &req);
773780
iput(inode);
@@ -1068,8 +1075,10 @@ static int ubifs_mknod(struct inode *dir, struct dentry *dentry,
10681075
}
10691076

10701077
err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm);
1071-
if (err)
1078+
if (err) {
1079+
kfree(dev);
10721080
goto out_budg;
1081+
}
10731082

10741083
sz_change = CALC_DENT_SIZE(fname_len(&nm));
10751084

@@ -1316,9 +1325,6 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
13161325
unsigned int uninitialized_var(saved_nlink);
13171326
struct fscrypt_name old_nm, new_nm;
13181327

1319-
if (flags & ~RENAME_NOREPLACE)
1320-
return -EINVAL;
1321-
13221328
/*
13231329
* Budget request settings: deletion direntry, new direntry, removing
13241330
* the old inode, and changing old and new parent directory inodes.

0 commit comments

Comments
 (0)