drm/msm/dsi: invalid parameter check in msm_dsi_phy_enable
PATCH 1/1 drm/msm/dsi: invalid parameter check in msm_dsi_phy_enable
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 5c8290284402b ("drm/msm/dsi: Split PHY drivers to separate files")
Addresses-Coverity-ID: 1493860 ("Null pointer dereference")
Signed-off-by José Expósito <[email protected]>
--- drivers/gpu/drm/msm/dsi/phy/dsi_phy.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/dsi/phy/dsi_phy.c +3 -1
@@ -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",
Signature · 1 line
2.25.1
Quoted 9 lines · José Expósito
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 5c8290284402b ("drm/msm/dsi: Split PHY drivers to separate files")Addresses-Coverity-ID: 1493860 ("Null pointer dereference")
Signed-off-by José Expósito <[email protected]>
Reviewed-by Dmitry Baryshkov <[email protected]>
Quoted 24 lines
--- drivers/gpu/drm/msm/dsi/phy/dsi_phy.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/msm/dsi/phy/dsi_phy.c +3
-1@@ -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",
Signature · 2 lines
With best wishes Dmitry