Re: [PATCH 1/3] drm/msm/dsi: check src_pll for null in dsi manager

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 12, 2018 at 3:55 PM, Lloyd Atkinson <latkinso@xxxxxxxxxxxxxx> wrote:
> Add checks for failure after retrieving the src_pll, since it
> may fail. This prevents an invalid pointer dereference later in
> msm_dsi_pll_get_clk_provider.
>
> Signed-off-by: Lloyd Atkinson <latkinso@xxxxxxxxxxxxxx>
> ---
>  drivers/gpu/drm/msm/dsi/dsi_manager.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_manager.c b/drivers/gpu/drm/msm/dsi/dsi_manager.c
> index 8552481..d276358 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_manager.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_manager.c
> @@ -88,6 +88,8 @@ static int dsi_mgr_setup_components(int id)
>
>                 msm_dsi_phy_set_usecase(msm_dsi->phy, MSM_DSI_PHY_STANDALONE);
>                 src_pll = msm_dsi_phy_get_pll(msm_dsi->phy);
> +               if (!src_pll)
> +                       return -EINVAL;

hmm, this is a bit awkward, and probably something that we should have
noticed/fixed by now.. but in case CONFIG_DRM_MSM_DSI_PLL is not
enabled, msm_dsi_pll_init() returns ERR_PTR(-ENODEV).  But if it is
enabled, then error paths return NULL.

Probably we should fix the enabled case to propagate back
ERR_PTR(errno) and never return NULL, and then use IS_ERR() here.

(I guess also IS_ERR_OR_NULL() here would do the job.. but perhaps
best to fix the root issue)

BR,
-R

>                 ret = msm_dsi_host_set_src_pll(msm_dsi->host, src_pll);
>         } else if (!other_dsi) {
>                 ret = 0;
> @@ -116,6 +118,8 @@ static int dsi_mgr_setup_components(int id)
>                 msm_dsi_phy_set_usecase(clk_slave_dsi->phy,
>                                         MSM_DSI_PHY_SLAVE);
>                 src_pll = msm_dsi_phy_get_pll(clk_master_dsi->phy);
> +               if (!src_pll)
> +                       return -EINVAL;
>                 ret = msm_dsi_host_set_src_pll(msm_dsi->host, src_pll);
>                 if (ret)
>                         return ret;
> --
> QUALCOMM Canada, on behalf of Qualcomm Innovation Center, Inc. is a member
> of Code Aurora Forum, hosted by The Linux Foundation
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux