Skip to content

Commit e19c29e

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: qnx4: don't leak ->BitMap on late failure exits qnx4: reduce the insane nesting in qnx4_checkroot() qnx4: di_fname is an array, for crying out loud... vfs: remove printk from set_nlink() wake up s_wait_unfrozen when ->freeze_fs fails
2 parents afd2909 + 8bc5191 commit e19c29e

File tree

3 files changed

+27
-40
lines changed

3 files changed

+27
-40
lines changed

fs/inode.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,6 @@ EXPORT_SYMBOL(clear_nlink);
322322
void set_nlink(struct inode *inode, unsigned int nlink)
323323
{
324324
if (!nlink) {
325-
printk_ratelimited(KERN_INFO
326-
"set_nlink() clearing i_nlink on %s inode %li\n",
327-
inode->i_sb->s_type->name, inode->i_ino);
328325
clear_nlink(inode);
329326
} else {
330327
/* Yes, some filesystems do change nlink from zero to one */

fs/qnx4/inode.c

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -179,47 +179,33 @@ static const char *qnx4_checkroot(struct super_block *sb)
179179
struct qnx4_inode_entry *rootdir;
180180
int rd, rl;
181181
int i, j;
182-
int found = 0;
183182

184-
if (*(qnx4_sb(sb)->sb->RootDir.di_fname) != '/') {
183+
if (*(qnx4_sb(sb)->sb->RootDir.di_fname) != '/')
185184
return "no qnx4 filesystem (no root dir).";
186-
} else {
187-
QNX4DEBUG((KERN_NOTICE "QNX4 filesystem found on dev %s.\n", sb->s_id));
188-
rd = le32_to_cpu(qnx4_sb(sb)->sb->RootDir.di_first_xtnt.xtnt_blk) - 1;
189-
rl = le32_to_cpu(qnx4_sb(sb)->sb->RootDir.di_first_xtnt.xtnt_size);
190-
for (j = 0; j < rl; j++) {
191-
bh = sb_bread(sb, rd + j); /* root dir, first block */
192-
if (bh == NULL) {
193-
return "unable to read root entry.";
194-
}
195-
for (i = 0; i < QNX4_INODES_PER_BLOCK; i++) {
196-
rootdir = (struct qnx4_inode_entry *) (bh->b_data + i * QNX4_DIR_ENTRY_SIZE);
197-
if (rootdir->di_fname != NULL) {
198-
QNX4DEBUG((KERN_INFO "rootdir entry found : [%s]\n", rootdir->di_fname));
199-
if (!strcmp(rootdir->di_fname,
200-
QNX4_BMNAME)) {
201-
found = 1;
202-
qnx4_sb(sb)->BitMap = kmemdup(rootdir,
203-
sizeof(struct qnx4_inode_entry),
204-
GFP_KERNEL);
205-
if (!qnx4_sb(sb)->BitMap) {
206-
brelse (bh);
207-
return "not enough memory for bitmap inode";
208-
}/* keep bitmap inode known */
209-
break;
210-
}
211-
}
212-
}
185+
QNX4DEBUG((KERN_NOTICE "QNX4 filesystem found on dev %s.\n", sb->s_id));
186+
rd = le32_to_cpu(qnx4_sb(sb)->sb->RootDir.di_first_xtnt.xtnt_blk) - 1;
187+
rl = le32_to_cpu(qnx4_sb(sb)->sb->RootDir.di_first_xtnt.xtnt_size);
188+
for (j = 0; j < rl; j++) {
189+
bh = sb_bread(sb, rd + j); /* root dir, first block */
190+
if (bh == NULL)
191+
return "unable to read root entry.";
192+
rootdir = (struct qnx4_inode_entry *) bh->b_data;
193+
for (i = 0; i < QNX4_INODES_PER_BLOCK; i++, rootdir++) {
194+
QNX4DEBUG((KERN_INFO "rootdir entry found : [%s]\n", rootdir->di_fname));
195+
if (strcmp(rootdir->di_fname, QNX4_BMNAME) != 0)
196+
continue;
197+
qnx4_sb(sb)->BitMap = kmemdup(rootdir,
198+
sizeof(struct qnx4_inode_entry),
199+
GFP_KERNEL);
213200
brelse(bh);
214-
if (found != 0) {
215-
break;
216-
}
217-
}
218-
if (found == 0) {
219-
return "bitmap file not found.";
201+
if (!qnx4_sb(sb)->BitMap)
202+
return "not enough memory for bitmap inode";
203+
/* keep bitmap inode known */
204+
return NULL;
220205
}
206+
brelse(bh);
221207
}
222-
return NULL;
208+
return "bitmap file not found.";
223209
}
224210

225211
static int qnx4_fill_super(struct super_block *s, void *data, int silent)
@@ -270,7 +256,7 @@ static int qnx4_fill_super(struct super_block *s, void *data, int silent)
270256
if (IS_ERR(root)) {
271257
printk(KERN_ERR "qnx4: get inode failed\n");
272258
ret = PTR_ERR(root);
273-
goto out;
259+
goto outb;
274260
}
275261

276262
ret = -ENOMEM;
@@ -283,6 +269,8 @@ static int qnx4_fill_super(struct super_block *s, void *data, int silent)
283269

284270
outi:
285271
iput(root);
272+
outb:
273+
kfree(qs->BitMap);
286274
out:
287275
brelse(bh);
288276
outnobh:

fs/super.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,8 @@ int freeze_super(struct super_block *sb)
11861186
printk(KERN_ERR
11871187
"VFS:Filesystem freeze failed\n");
11881188
sb->s_frozen = SB_UNFROZEN;
1189+
smp_wmb();
1190+
wake_up(&sb->s_wait_unfrozen);
11891191
deactivate_locked_super(sb);
11901192
return ret;
11911193
}

0 commit comments

Comments
 (0)