From 6854e171a54931f6497dfb87a57f181d9c30b3b4 Mon Sep 17 00:00:00 2001 From: Shi Zhongbo Date: Thu, 8 Aug 2019 13:23:07 +0800 Subject: [PATCH] msm: vidc: fix kw issues Fix two kw issues on uninitialized pointer and possible NULL dereference. Change-Id: Ic87335d435ee84bef1c264d99e0d857d2932cbdc Signed-off-by: Shi Zhongbo --- msm/vidc/msm_vidc_buffer_calculations.c | 16 +++++++++++++++- msm/vidc/msm_vidc_common.c | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/msm/vidc/msm_vidc_buffer_calculations.c b/msm/vidc/msm_vidc_buffer_calculations.c index 2a820415c1f5..13200fc29a58 100644 --- a/msm/vidc/msm_vidc_buffer_calculations.c +++ b/msm/vidc/msm_vidc_buffer_calculations.c @@ -746,6 +746,13 @@ static int msm_vidc_get_extra_input_buff_count(struct msm_vidc_inst *inst) struct msm_vidc_core *core; struct v4l2_format *f; + if (!inst || !inst->core) { + dprintk(VIDC_ERR, "%s: invalid params\n", __func__); + return -EINVAL; + } + + core = inst->core; + /* * For a non-realtime session, extra buffers are not required. * For thumbnail session, extra buffers are not required as @@ -815,6 +822,13 @@ static int msm_vidc_get_extra_output_buff_count(struct msm_vidc_inst *inst) struct msm_vidc_core *core; struct v4l2_format *f; + if (!inst || !inst->core) { + dprintk(VIDC_ERR, "%s: invalid params\n", __func__); + return -EINVAL; + } + + core = inst->core; + /* * For a non-realtime session, extra buffers are not required. * For thumbnail session, extra buffers are not required as @@ -840,7 +854,7 @@ static int msm_vidc_get_extra_output_buff_count(struct msm_vidc_inst *inst) */ if (core->resources.decode_batching) extra_output_count = BATCH_DEC_EXTRA_OUTPUT_BUFFERS; - else if (inst->core->resources.dcvs) + else if (core->resources.dcvs) extra_output_count = DCVS_DEC_EXTRA_OUTPUT_BUFFERS; } else if (is_encode_session(inst)) { /* diff --git a/msm/vidc/msm_vidc_common.c b/msm/vidc/msm_vidc_common.c index be2b6d25485e..b9cc0dabc1bf 100644 --- a/msm/vidc/msm_vidc_common.c +++ b/msm/vidc/msm_vidc_common.c @@ -4588,7 +4588,7 @@ int msm_comm_qbufs_batch(struct msm_vidc_inst *inst, struct msm_vidc_buffer *buf; int do_bw_calc = 0; - do_bw_calc = mbuf->vvb.vb2_buf.type == INPUT_MPLANE; + do_bw_calc = mbuf ? mbuf->vvb.vb2_buf.type == INPUT_MPLANE : 0; rc = msm_comm_scale_clocks_and_bus(inst, do_bw_calc); if (rc) dprintk(VIDC_ERR, "%s: scale clock & bw failed\n", __func__);