Skip to content

Commit

Permalink
fs/romfs: correct error-handling code
Browse files Browse the repository at this point in the history
romfs_iget returns an ERR_PTR value in an error case instead of NULL.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@match exists@
expression x, E;
statement S1, S2;
@@

x = romfs_iget(...)
... when != x = E
(
*  if (x == NULL || ...) S1 else S2
|
*  if (x == NULL && ...) S1 else S2
)
// </smpl>

Signed-off-by: Julia Lawall <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Julia Lawall authored and torvalds committed Sep 24, 2009
1 parent 9e5f113 commit a21f3c2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/romfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ static int romfs_fill_super(struct super_block *sb, void *data, int silent)
pos = (ROMFH_SIZE + len + 1 + ROMFH_PAD) & ROMFH_MASK;

root = romfs_iget(sb, pos);
if (!root)
if (IS_ERR(root))
goto error;

sb->s_root = d_alloc_root(root);
Expand Down

0 comments on commit a21f3c2

Please sign in to comment.