Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 87783690 authored by Namhyung Kim's avatar Namhyung Kim Committed by Theodore Ts'o
Browse files

ext4: Check return value of sb_getblk() and friends



Fail block allocation if sb_getblk() returns NULL. In that case,
sb_find_get_block() also likely to fail so that it should skip
calling ext4_forget().

Signed-off-by: default avatarNamhyung Kim <namhyung@gmail.com>
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent bd2d0210
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -761,6 +761,11 @@ static int ext4_alloc_branch(handle_t *handle, struct inode *inode,
		 * parent to disk.
		 */
		bh = sb_getblk(inode->i_sb, new_blocks[n-1]);
		if (unlikely(!bh)) {
			err = -EIO;
			goto failed;
		}

		branch[n].bh = bh;
		lock_buffer(bh);
		BUFFER_TRACE(bh, "call get_create_access");
+2 −0
Original line number Diff line number Diff line
@@ -4537,6 +4537,8 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode,
			if (!bh)
				tbh = sb_find_get_block(inode->i_sb,
							block + i);
			if (unlikely(!tbh))
				continue;
			ext4_forget(handle, flags & EXT4_FREE_BLOCKS_METADATA,
				    inode, tbh, block + i);
		}