disp: msm: add proper null checks and propagate error

Fix possible null pointer dereferencing and propagate error
code during early return.

Signed-off-by: Samantha Tran <samtran@codeaurora.org>
This commit is contained in:
Samantha Tran
2019-08-06 13:46:48 -07:00
parent c70f647143
commit c00bf10768
2 changed files with 10 additions and 3 deletions

View File

@@ -378,8 +378,10 @@ struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev,
const struct drm_format_info *info;
info = drm_format_info(mode_cmd->pixel_format);
if (!info || num_planes > ARRAY_SIZE(info->cpp))
if (!info || num_planes > ARRAY_SIZE(info->cpp)) {
ret = -EINVAL;
goto fail;
}
for (i = 0; i < num_planes; i++) {
unsigned int width = mode_cmd->width / (i ? hsub : 1);