Skip to content

Commit 4d06bfb

Browse files
riteshharjanitytso
authored andcommitted
ext4: Add error handling for io_end_vec struct allocation
This patch adds the error handling in case of any memory allocation failure for io_end_vec. This was missing in original patch series which enables dioread_nolock for blocksize < pagesize. Fixes: c8cc881 ("ext4: Add support for blocksize < pagesize in dioread_nolock") Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com> Link: https://lore.kernel.org/r/20191106093809.10673-1-riteshh@linux.ibm.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 8d0d47e commit 4d06bfb

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎fs/ext4/inode.c‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2240,6 +2240,10 @@ static int mpage_process_page(struct mpage_da_data *mpd, struct page *page,
22402240
err = 0;
22412241
if (!err && mpd->map.m_len && mpd->map.m_lblk > lblk) {
22422242
io_end_vec = ext4_alloc_io_end_vec(io_end);
2243+
if (IS_ERR(io_end_vec)) {
2244+
err = PTR_ERR(io_end_vec);
2245+
goto out;
2246+
}
22432247
io_end_vec->offset = mpd->map.m_lblk << blkbits;
22442248
}
22452249
*map_bh = true;
@@ -2405,8 +2409,11 @@ static int mpage_map_and_submit_extent(handle_t *handle,
24052409
loff_t disksize;
24062410
int progress = 0;
24072411
ext4_io_end_t *io_end = mpd->io_submit.io_end;
2408-
struct ext4_io_end_vec *io_end_vec = ext4_alloc_io_end_vec(io_end);
2412+
struct ext4_io_end_vec *io_end_vec;
24092413

2414+
io_end_vec = ext4_alloc_io_end_vec(io_end);
2415+
if (IS_ERR(io_end_vec))
2416+
return PTR_ERR(io_end_vec);
24102417
io_end_vec->offset = ((loff_t)map->m_lblk) << inode->i_blkbits;
24112418
do {
24122419
err = mpage_map_one_extent(handle, mpd);

0 commit comments

Comments
 (0)