[RHEL7,COMMIT] ms/ext4: fix error handling in ext4_ext_shift_extents

Submitted by Konstantin Khorenko on June 16, 2020, 10:59 a.m.

Details

Message ID 202006161059.05GAx07X030772@finist-ce7.sw.ru
State New
Headers show

Patch hide | download patch | download mbox

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 78dd03a0453c4..0a636ff128982 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -5416,11 +5416,18 @@  ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
 	 * enough to accomodate the shift.
 	 */
 	path = ext4_ext_find_extent(inode, start - 1, NULL, 0);
+	if (IS_ERR(path))
+		return PTR_ERR(path);
 	depth = path->p_depth;
 	extent =  path[depth].p_ext;
-	ex_start = le32_to_cpu(extent->ee_block);
-	ex_end = le32_to_cpu(extent->ee_block) +
+	if (extent) {
+		ex_start = le32_to_cpu(extent->ee_block);
+		ex_end = le32_to_cpu(extent->ee_block) +
 			ext4_ext_get_actual_len(extent);
+	} else {
+		ex_start = 0;
+		ex_end = 0;
+	}
 	ext4_ext_drop_refs(path);
 	kfree(path);