From b62727af64a3d8c5a5edb6654f8203178a7aea29 Mon Sep 17 00:00:00 2001 From: Govindaraj Rajagopal Date: Tue, 9 Jun 2020 10:54:08 +0530 Subject: [PATCH] msm: vidc: Bail_out missing platform_data cases during probe During msm_vidc_probe, core->platform_data will be NULL, if there is no match with compatible string in the of_dt table. In msm_decide_dt_node sku-index check will be by passed due to default value(0) i.e leading to NULL ptr dereference exception in msm_vidc_init_core_clk_ops. So added check to avoid subsequent calls, if core->platform_data is NULL. Change-Id: I335a2836b2e34e79dcb8743816205d23f798617d Signed-off-by: Govindaraj Rajagopal --- msm/vidc/msm_v4l2_vidc.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/msm/vidc/msm_v4l2_vidc.c b/msm/vidc/msm_v4l2_vidc.c index 53eee0685228..48d435af9fbc 100644 --- a/msm/vidc/msm_v4l2_vidc.c +++ b/msm/vidc/msm_v4l2_vidc.c @@ -261,17 +261,28 @@ static int read_platform_resources(struct msm_vidc_core *core, __func__, core, pdev); return -EINVAL; } + if (!pdev->dev.of_node) { + d_vpr_e("%s: pdev node is NULL\n", __func__); + return -EINVAL; + } + core->hfi_type = VIDC_HFI_VENUS; core->resources.pdev = pdev; - if (pdev->dev.of_node) { - /* Target supports DT, parse from it */ - rc = read_platform_resources_from_drv_data(core); - rc = read_platform_resources_from_dt(&core->resources); - } else { - d_vpr_e("pdev node is NULL\n"); - rc = -EINVAL; + /* Target supports DT, parse from it */ + rc = read_platform_resources_from_drv_data(core); + if (rc) { + d_vpr_e("%s: read platform resources from driver failed\n", + __func__); + return rc; } - return rc; + + rc = read_platform_resources_from_dt(&core->resources); + if (rc) { + d_vpr_e("%s: read platform resources from dt failed\n", + __func__); + return rc; + } + return 0; } static int msm_vidc_initialize_core(struct platform_device *pdev,