drm/msm: dsi: Initialize msm_dsi->id to -1
authorSean Paul <seanpaul@chromium.org>
Mon, 30 Jul 2018 15:26:53 +0000 (11:26 -0400)
committerRob Clark <robdclark@gmail.com>
Thu, 4 Oct 2018 00:24:49 +0000 (20:24 -0400)
Currently msm_dsi->id is initialized to 0 during kzalloc. If bind fails
for a secondary dsi device before its id can be properly set (such as
during dt parsing), the id will point to the primary dsi device, causing
its reference to be removed from dsi_manager's global (msm_dsim_glb)
array.

This patch initializes the id to -1 and checks for negative in the
manager cleanup.

Cc: Doug Anderson <dianders@chromium.org>
Reviewed-by: Abhinav Kumar <abhinavk@codeaurora.org>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
drivers/gpu/drm/msm/dsi/dsi.c
drivers/gpu/drm/msm/dsi/dsi_manager.c

index ff8164cc6738d8d16499862e620a999330a7aaf7..ee07d58c2d9791acf4a36c5ea35d31751082af1c 100644 (file)
@@ -83,6 +83,7 @@ static struct msm_dsi *dsi_init(struct platform_device *pdev)
                return ERR_PTR(-ENOMEM);
        DBG("dsi probed=%p", msm_dsi);
 
+       msm_dsi->id = -1;
        msm_dsi->pdev = pdev;
        platform_set_drvdata(pdev, msm_dsi);
 
index 5224010d90e4ac0cb78a66b1e785586ff514087f..80aa6344185e13068ad4442e069fbe2a91cb1e52 100644 (file)
@@ -839,6 +839,8 @@ void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi)
 
        if (msm_dsi->host)
                msm_dsi_host_unregister(msm_dsi->host);
-       msm_dsim->dsi[msm_dsi->id] = NULL;
+
+       if (msm_dsi->id >= 0)
+               msm_dsim->dsi[msm_dsi->id] = NULL;
 }