Forráskód Böngészése

disp: msm: add array out of bounds index check

Add check for plane used as index on accessing
for bytes per pixel value.

Change-Id: I3642f9a57bf2eee7fa0dbf0965bd8497f3911e18
Signed-off-by: Prashant Singh <[email protected]>
Prashant Singh 6 éve
szülő
commit
0c5e316fe9
1 módosított fájl, 7 hozzáadás és 1 törlés
  1. 7 1
      msm/msm_fb.c

+ 7 - 1
msm/msm_fb.c

@@ -375,11 +375,17 @@ struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev,
 				goto fail;
 		}
 	} else {
+		const struct drm_format_info *info;
+
+		info = drm_format_info(mode_cmd->pixel_format);
+		if (!info || num_planes > ARRAY_SIZE(info->cpp))
+			goto fail;
+
 		for (i = 0; i < num_planes; i++) {
 			unsigned int width = mode_cmd->width / (i ? hsub : 1);
 			unsigned int height = mode_cmd->height / (i ? vsub : 1);
 			unsigned int min_size;
-			unsigned int cpp;
+			unsigned int cpp = 0;
 
 			cpp = drm_format_plane_cpp(mode_cmd->pixel_format, i);