summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/msm/edp
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2021-09-29 15:18:57 +0300
committerRob Clark <robdclark@chromium.org>2021-10-12 03:30:53 +0300
commit2133c4fc8e1348dcb752f267a143fe2254613b34 (patch)
treefca18df1a4201ba4ffe3f81f5ee91327d381564d /drivers/gpu/drm/msm/edp
parentc491a0c7bbf3a64732cb8414021429d15ec08eec (diff)
downloadlinux-2133c4fc8e1348dcb752f267a143fe2254613b34.tar.xz
drm/msm: Fix null pointer dereference on pointer edp
The initialization of pointer dev dereferences pointer edp before edp is null checked, so there is a potential null pointer deference issue. Fix this by only dereferencing edp after edp has been null checked. Addresses-Coverity: ("Dereference before null check") Fixes: ab5b0107ccf3 ("drm/msm: Initial add eDP support in msm drm driver (v5)") Signed-off-by: Colin Ian King <colin.king@canonical.com> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Link: https://lore.kernel.org/r/20210929121857.213922-1-colin.king@canonical.com Signed-off-by: Rob Clark <robdclark@chromium.org>
Diffstat (limited to 'drivers/gpu/drm/msm/edp')
-rw-r--r--drivers/gpu/drm/msm/edp/edp_ctrl.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/gpu/drm/msm/edp/edp_ctrl.c b/drivers/gpu/drm/msm/edp/edp_ctrl.c
index 4fb397ee7c84..fe1366b4c49f 100644
--- a/drivers/gpu/drm/msm/edp/edp_ctrl.c
+++ b/drivers/gpu/drm/msm/edp/edp_ctrl.c
@@ -1116,7 +1116,7 @@ void msm_edp_ctrl_power(struct edp_ctrl *ctrl, bool on)
int msm_edp_ctrl_init(struct msm_edp *edp)
{
struct edp_ctrl *ctrl = NULL;
- struct device *dev = &edp->pdev->dev;
+ struct device *dev;
int ret;
if (!edp) {
@@ -1124,6 +1124,7 @@ int msm_edp_ctrl_init(struct msm_edp *edp)
return -EINVAL;
}
+ dev = &edp->pdev->dev;
ctrl = devm_kzalloc(dev, sizeof(*ctrl), GFP_KERNEL);
if (!ctrl)
return -ENOMEM;