Procházet zdrojové kódy

msm: camera: cre: Fix out-of-bounds access in cre driver

This change fixes possible out-of-bounds access while updating
cre_bus_rd by adding check if the port index is proper.

CRs-Fixed: 3595684
Change-Id: I10f2f7174f9df75118dbb1efed60e870ac2ac97f
Signed-off-by: Abhilash Kumar <[email protected]>
(cherry picked from commit 410038d0ec8a80e7ed2d04ed9bd98f60a0d5de12)
Abhilash Kumar před 1 rokem
rodič
revize
66e737396c

+ 4 - 0
drivers/cam_cre/cam_cre_hw_mgr/cre_hw/bus_rd/cre_bus_rd.c

@@ -139,6 +139,10 @@ static int cam_cre_bus_rd_update(struct cam_cre_hw *cam_cre_hw_info,
 
 	in_port_idx =
 	cam_cre_bus_rd_in_port_idx(io_buf->resource_type);
+	if (in_port_idx < 0) {
+		CAM_ERR(CAM_CRE, "Invalid in_port_idx for resource %d", io_buf->resource_type);
+		return -EINVAL;
+	}
 
 	CAM_DBG(CAM_CRE, "in_port_idx %d", in_port_idx);
 	for (k = 0; k < io_buf->num_planes; k++) {