romfs: fix returm err while getting inode in fill_super
PATCH 1/2 romfs: fix returm err while getting inode in fill_super
Getting an inode by romfs_iget may lead to an err in fill_super, and the err value should be return.
And it should return -ENOMEM instead while d_make_root fails, fix it too.
--- fs/romfs/super.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/romfs/super.c +2 -4
@@ -533,16 +533,14 @@ static int romfs_fill_super(struct super_block *sb, void *data, int silent) root =romfs_iget (sb, pos);if (IS_ERR (root)) - goto error; +return PTR_ERR (root); sb->s_root =d_make_root (root);if (!sb->s_root) - goto error; +return -ENOMEM ;return 0 ; -error: -return -EINVAL ; error_rsb_inval: ret = -EINVAL ; error_rsb:
Signature · 1 line
1.8.2.2
PATCH 2/2 romfs: remove an redundant if condition in romfs_readpage
Here ret always equals 0, so SetPageUptodate directly.
--- fs/romfs/super.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/romfs/super.c +1 -2
@@ -129,8 +129,7 @@ static int romfs_readpage(struct file *file, struct page *page)if (fillsize <PAGE_SIZE )memset (buf + fillsize,0 ,PAGE_SIZE - fillsize); -if (ret ==0 ) -SetPageUptodate (page); +SetPageUptodate (page);flush_dcache_page (page);kunmap (page);
Signature · 1 line
1.8.2.2
Re: [PATCH 2/2] romfs: remove an redundant if condition in romfs_readpage
Quoted 7 lines · On Tue, 26 Nov 2013 16:39:09 +0800 Rui Xiang <[email protected]> wrote:
Here ret always equals 0, so SetPageUptodate directly.
...
fs/romfs/super.c static int romfs_readpage(struct file *file, struct page *page) · line 135
Quoted 9 lines
fs/romfs/super.c +1
-2@@ -129,8 +129,7 @@ static int romfs_readpage(struct file *file, struct page *page)if (fillsize <PAGE_SIZE )memset (buf + fillsize,0 ,PAGE_SIZE - fillsize); -if (ret ==0 ) -SetPageUptodate (page); +SetPageUptodate (page);flush_dcache_page (page);kunmap (page);
Nope, `ret' can be -EIO:
ret = 0;
if (offset < size) {
size -= offset;
fillsize = size > PAGE_SIZE ? PAGE_SIZE : size;
pos = ROMFS_I(inode)->i_dataoffset + offset;
ret = romfs_dev_read(inode->i_sb, pos, buf, fillsize);
if (ret < 0) {
SetPageError(page);
fillsize = 0;
-->> ret = -EIO;
}
}
if (fillsize < PAGE_SIZE)
memset(buf + fillsize, 0, PAGE_SIZE - fillsize);
if (ret == 0)
SetPageUptodate(page);It was a bit rude to overwrite the romfs_dev_read() return code though.
Re: [PATCH 2/2] romfs: remove an redundant if condition in romfs_readpage
Quoted 42 lines · Andrew Morton
Quoted 7 lines · On Tue, 26 Nov 2013 16:39:09 +0800 Rui Xiang <[email protected]> wrote:
Here ret always equals 0, so SetPageUptodate directly.
...
fs/romfs/super.c static int romfs_readpage(struct file *file, struct page *page) · line 135
Quoted 9 lines
fs/romfs/super.c +1
-2@@ -129,8 +129,7 @@ static int romfs_readpage(struct file *file, struct page *page)if (fillsize <PAGE_SIZE )memset (buf + fillsize,0 ,PAGE_SIZE - fillsize); -if (ret ==0 ) -SetPageUptodate (page); +SetPageUptodate (page);flush_dcache_page (page);kunmap (page);Nope, `ret' can be
-EIO:ret = 0; if (offset < size) { size -= offset; fillsize = size > PAGE_SIZE ? PAGE_SIZE : size; pos = ROMFS_I(inode)->i_dataoffset + offset; ret = romfs_dev_read(inode->i_sb, pos, buf, fillsize); if (ret < 0) { SetPageError(page); fillsize = 0; -->> ret = -EIO; } } if (fillsize < PAGE_SIZE) memset(buf + fillsize, 0, PAGE_SIZE - fillsize); if (ret == 0) SetPageUptodate(page);
Quoted 2 lines
It was a bit rude to overwrite the
romfs_dev_read()return code though.
Ah, my fault. Ignore that, please.