Skip to content

Commit

Permalink
ext4_get_link(): fix breakage in RCU mode
Browse files Browse the repository at this point in the history
1) errors from ext4_getblk() should not be propagated to caller
unless we are really sure that we would've gotten the same error
in non-RCU pathwalk.
2) we leak buffer_heads if ext4_getblk() is successful, but bh is
not uptodate.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Feb 25, 2024
1 parent 0511fdb commit 9fa8e28
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions fs/ext4/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,12 @@ static const char *ext4_get_link(struct dentry *dentry, struct inode *inode,

if (!dentry) {
bh = ext4_getblk(NULL, inode, 0, EXT4_GET_BLOCKS_CACHED_NOWAIT);
if (IS_ERR(bh))
return ERR_CAST(bh);
if (!bh || !ext4_buffer_uptodate(bh))
if (IS_ERR(bh) || !bh)
return ERR_PTR(-ECHILD);
if (!ext4_buffer_uptodate(bh)) {
brelse(bh);
return ERR_PTR(-ECHILD);
}
} else {
bh = ext4_bread(NULL, inode, 0, 0);
if (IS_ERR(bh))
Expand Down

0 comments on commit 9fa8e28

Please sign in to comment.