]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/msm/dsi: invalid parameter check in msm_dsi_phy_enable
authorJosé Expósito <jose.exposito89@gmail.com>
Sun, 16 Jan 2022 18:18:44 +0000 (19:18 +0100)
committerDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Tue, 25 Jan 2022 02:48:13 +0000 (05:48 +0300)
The function performs a check on the "phy" input parameter, however, it
is used before the check.

Initialize the "dev" variable after the sanity check to avoid a possible
NULL pointer dereference.

Fixes: 5fe7f7a0b8270 ("drm/msm/dsi: Split PHY drivers to separate files")
Addresses-Coverity-ID: 1493860 ("Null pointer dereference")
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20220116181844.7400-1-jose.exposito89@gmail.com
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
drivers/gpu/drm/msm/dsi/phy/dsi_phy.c

index c2ed177717c74c0552a97bc68d7e65b2971be41f..2027b38617ab2d11487b4c62a236def96d5793a0 100644 (file)
@@ -808,12 +808,14 @@ int msm_dsi_phy_enable(struct msm_dsi_phy *phy,
                        struct msm_dsi_phy_clk_request *clk_req,
                        struct msm_dsi_phy_shared_timings *shared_timings)
 {
-       struct device *dev = &phy->pdev->dev;
+       struct device *dev;
        int ret;
 
        if (!phy || !phy->cfg->ops.enable)
                return -EINVAL;
 
+       dev = &phy->pdev->dev;
+
        ret = dsi_phy_enable_resource(phy);
        if (ret) {
                DRM_DEV_ERROR(dev, "%s: resource enable failed, %d\n",