adding NULL check before dereferencing a pointer.
Change-Id: I260b016abdcb16f5b16e58671ed208df21c99a46
Signed-off-by: Suprith Malligere Shankaregowda <supgow@codeaurora.org>
/*
- * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
rc = dsi_display_get_modes(display, NULL, &count);
if (rc) {
pr_err("failed to get num of modes, rc=%d\n", rc);
- goto error;
+ goto end;
}
size = count * sizeof(*modes);
kfree(to_mdp5_plane_state(plane->state));
mdp5_state = kzalloc(sizeof(*mdp5_state), GFP_KERNEL);
-
+ if (!mdp5_state)
+ return;
/* assign default blend parameters */
mdp5_state->alpha = 255;
mdp5_state->premultiplied = 0;
bool vflip, hflip;
unsigned long flags;
int ret;
+ const struct msm_format *msm_fmt;
+ msm_fmt = msm_framebuffer_format(fb);
nplanes = drm_format_num_planes(fb->pixel_format);
/* bad formats should already be rejected: */
if (WARN_ON(nplanes > pipe2nclients(pipe)))
return -EINVAL;
- format = to_mdp_format(msm_framebuffer_format(fb));
+ if (!msm_fmt) {
+ pr_err("invalid format");
+ return -EINVAL;
+ }
+
+ format = to_mdp_format(msm_fmt);
pix_format = format->base.pixel_format;
/* src values are in Q16 fixed point, convert to integer: */
* to do it page-by-page, w/ kmap() if not vmap()d..
*/
ptr = msm_gem_vaddr(&obj->base);
+ if (!ptr) {
+ DRM_ERROR("Invalid format");
+ return -EINVAL;
+ }
if (IS_ERR(ptr)) {
ret = PTR_ERR(ptr);
/* Get the parent device */
parent = of_find_device_by_node(node->parent);
-
+ if (!parent)
+ return ERR_PTR(-ENODEV);
/* Populate the sub nodes */
of_platform_populate(parent->dev.of_node, NULL, NULL, &parent->dev);