msm: mdss: Fix potential NULL pointer dereferences

Fixing potential NULL pointer dereferences in MDSS driver.

Change-Id: I1d8013f4b9079bfd3e142326d92ec4e6bb90c147
Signed-off-by: Krishna Chaitanya Devarakonda <kdevarak@codeaurora.org>
This commit is contained in:
Krishna Chaitanya Devarakonda 2016-07-12 15:49:42 +05:30 committed by Harsh Sahu
parent 99b8438d0e
commit 4ba1744f2e
9 changed files with 45 additions and 20 deletions

View file

@ -197,7 +197,7 @@ static struct mdp_input_layer *__create_layer_list(
struct mdp_input_layer32 *layer_list32,
u32 layer_count)
{
int i, ret;
int i, ret = 0;
u32 buffer_size;
struct mdp_input_layer *layer, *layer_list;
struct mdp_input_layer32 *layer32;

View file

@ -633,7 +633,7 @@ static int hdcp_1x_authentication_part1(struct hdcp_1x_ctrl *hdcp_ctrl)
u8 aksv[5], *bksv = NULL;
u8 an[8];
u8 bcaps = 0;
u32 link0_status;
u32 link0_status = 0;
u8 buf[0xFF];
struct scm_hdcp_req scm_buf[SCM_HDCP_MAX_REG];
u32 phy_addr;

View file

@ -369,9 +369,14 @@ static inline bool hdmi_tx_is_panel_on(struct hdmi_tx_ctrl *hdmi_ctrl)
static inline bool hdmi_tx_is_cec_wakeup_en(struct hdmi_tx_ctrl *hdmi_ctrl)
{
void *fd = hdmi_tx_get_fd(HDMI_TX_FEAT_CEC_HW);
void *fd = NULL;
if (!hdmi_ctrl || !fd)
if (!hdmi_ctrl)
return false;
fd = hdmi_tx_get_fd(HDMI_TX_FEAT_CEC_HW);
if (!fd)
return false;
return hdmi_cec_is_wakeup_en(fd);
@ -379,9 +384,14 @@ static inline bool hdmi_tx_is_cec_wakeup_en(struct hdmi_tx_ctrl *hdmi_ctrl)
static inline void hdmi_tx_cec_device_suspend(struct hdmi_tx_ctrl *hdmi_ctrl)
{
void *fd = hdmi_tx_get_fd(HDMI_TX_FEAT_CEC_HW);
void *fd = NULL;
if (!hdmi_ctrl || !fd)
if (!hdmi_ctrl)
return;
fd = hdmi_tx_get_fd(HDMI_TX_FEAT_CEC_HW);
if (!fd)
return;
hdmi_cec_device_suspend(fd, hdmi_ctrl->panel_suspend);

View file

@ -2409,12 +2409,12 @@ static void __update_sspp_info(struct mdss_mdp_pipe *pipe,
#define SPRINT(fmt, ...) \
(*cnt += scnprintf(buf + *cnt, len - *cnt, fmt, ##__VA_ARGS__))
for (i = 0; i < pipe_cnt; i++) {
for (i = 0; i < pipe_cnt && pipe; i++) {
SPRINT("pipe_num:%d pipe_type:%s pipe_ndx:%d rects:%d pipe_is_handoff:%d display_id:%d ",
pipe->num, type, pipe->ndx, pipe->multirect.max_rects,
pipe->is_handed_off, mdss_mdp_get_display_id(pipe));
SPRINT("fmts_supported:");
for (j = 0; j < num_bytes && pipe; j++)
for (j = 0; j < num_bytes; j++)
SPRINT("%d,", pipe->supported_formats[j]);
SPRINT("\n");
pipe += pipe->multirect.max_rects;
@ -3391,15 +3391,18 @@ static int mdss_mdp_parse_dt_pipe(struct platform_device *pdev)
mdss_mdp_parse_dt_handler(pdev, "qcom,mdss-pipe-sw-reset-off",
&sw_reset_offset, 1);
if (sw_reset_offset) {
mdss_mdp_parse_dt_pipe_sw_reset(pdev, sw_reset_offset,
"qcom,mdss-pipe-vig-sw-reset-map", mdata->vig_pipes,
mdata->nvig_pipes);
mdss_mdp_parse_dt_pipe_sw_reset(pdev, sw_reset_offset,
"qcom,mdss-pipe-rgb-sw-reset-map", mdata->rgb_pipes,
mdata->nrgb_pipes);
mdss_mdp_parse_dt_pipe_sw_reset(pdev, sw_reset_offset,
"qcom,mdss-pipe-dma-sw-reset-map", mdata->dma_pipes,
mdata->ndma_pipes);
if (mdata->vig_pipes)
mdss_mdp_parse_dt_pipe_sw_reset(pdev, sw_reset_offset,
"qcom,mdss-pipe-vig-sw-reset-map",
mdata->vig_pipes, mdata->nvig_pipes);
if (mdata->rgb_pipes)
mdss_mdp_parse_dt_pipe_sw_reset(pdev, sw_reset_offset,
"qcom,mdss-pipe-rgb-sw-reset-map",
mdata->rgb_pipes, mdata->nrgb_pipes);
if (mdata->dma_pipes)
mdss_mdp_parse_dt_pipe_sw_reset(pdev, sw_reset_offset,
"qcom,mdss-pipe-dma-sw-reset-map",
mdata->dma_pipes, mdata->ndma_pipes);
}
mdata->has_panic_ctrl = of_property_read_bool(pdev->dev.of_node,

View file

@ -2136,7 +2136,7 @@ static int __validate_multirect(struct msm_fb_data_type *mfd,
static int __validate_layers(struct msm_fb_data_type *mfd,
struct file *file, struct mdp_layer_commit_v1 *commit)
{
int ret, i;
int ret, i = 0;
int rec_ndx[MDSS_MDP_PIPE_MAX_RECTS] = { 0 };
int rec_release_ndx[MDSS_MDP_PIPE_MAX_RECTS] = { 0 };
int rec_destroy_ndx[MDSS_MDP_PIPE_MAX_RECTS] = { 0 };

View file

@ -3699,6 +3699,9 @@ static ssize_t mdss_mdp_misr_store(struct device *dev,
return rc;
}
req.block_id = DISPLAY_MISR_MAX;
sreq.block_id = DISPLAY_MISR_MAX;
pr_debug("intf_type:%d enable:%d\n", ctl->intf_type, enable_misr);
if (ctl->intf_type == MDSS_INTF_DSI) {

View file

@ -2598,7 +2598,8 @@ static int mdss_mdp_set_ts_pipe(struct mdss_mdp_pipe *pipe)
__get_ordered_rects(pipe, &low_pipe, &high_pipe);
ts_count_low = __get_ts_count(low_pipe, mixer, true);
ts_count_high = __get_ts_count(high_pipe, mixer, false);
if (high_pipe != NULL)
ts_count_high = __get_ts_count(high_pipe, mixer, false);
ts_bytes = __get_ts_bytes(pipe, mixer);
if (low_pipe->multirect.num == MDSS_MDP_PIPE_RECT0) {

View file

@ -2519,7 +2519,9 @@ static int pp_dspp_setup(u32 disp_num, struct mdss_mdp_mixer *mixer)
DSPP);
}
pp_dspp_opmode_config(ctl, dspp_num, pp_sts, mdata->mdp_rev, &opmode);
if (pp_sts != NULL)
pp_dspp_opmode_config(ctl, dspp_num, pp_sts, mdata->mdp_rev,
&opmode);
if (ad_hw) {
mutex_lock(&ad->lock);

View file

@ -195,6 +195,12 @@ int mdss_mdp_wfd_setup(struct mdss_mdp_wfd *wfd,
fmt = mdss_mdp_get_format_params(layer->buffer.format);
if (fmt == NULL) {
pr_err("invalid buffer format\n");
ret = -EINVAL;
goto wfd_setup_error;
}
/* only 3 csc type supported */
if (fmt->is_yuv) {
switch (layer->color_space) {