disp: msm: Address static analysis issues

Avoid various possible nullptr dereferences.
Addresses various issues highlighted by static analysis.

Change-Id: I36d34d610b37bf2799a7e34cd1de8b909b5c0ae4
Signed-off-by: Nisarg Bhavsar <quic_bhavsar@quicinc.com>
此提交包含在:
Nisarg Bhavsar
2022-04-22 09:27:21 -07:00
提交者 Amine Najahi
父節點 609f084c8a
當前提交 75aedb1c53
共有 6 個檔案被更改,包括 19 行新增17 行删除

查看文件

@@ -345,7 +345,7 @@ struct dp_hpd *dp_lphw_hpd_get(struct device *dev, struct dp_parser *parser,
{
int rc = 0;
const char *hpd_gpio_name = "qcom,dp-hpd-gpio";
struct dp_lphw_hpd_private *lphw_hpd;
struct dp_lphw_hpd_private *lphw_hpd = NULL;
unsigned int gpio;
if (!dev || !parser || !cb) {
@@ -358,7 +358,7 @@ struct dp_hpd *dp_lphw_hpd_get(struct device *dev, struct dp_parser *parser,
if (!gpio_is_valid(gpio)) {
DP_DEBUG("%s gpio not specified\n", hpd_gpio_name);
rc = -EINVAL;
goto gpio_error;
goto error;
}
lphw_hpd = devm_kzalloc(dev, sizeof(*lphw_hpd), GFP_KERNEL);

查看文件

@@ -621,7 +621,7 @@ int dsi_conn_get_mode_info(struct drm_connector *connector,
convert_to_dsi_mode(drm_mode, &partial_dsi_mode);
rc = dsi_display_find_mode(dsi_display, &partial_dsi_mode, sub_mode, &dsi_mode);
if (rc || !dsi_mode->priv_info)
if (rc || !dsi_mode->priv_info || !dsi_display || !dsi_display->panel)
return -EINVAL;
memset(mode_info, 0, sizeof(*mode_info));
@@ -641,12 +641,12 @@ int dsi_conn_get_mode_info(struct drm_connector *connector,
mode_info->qsync_min_fps = dsi_mode->timing.qsync_min_fps;
mode_info->wd_jitter = dsi_mode->priv_info->wd_jitter;
if (dsi_display->panel)
mode_info->vpadding = dsi_display->panel->host_config.vpadding;
mode_info->vpadding = dsi_display->panel->host_config.vpadding;
if (mode_info->vpadding < drm_mode->vdisplay) {
mode_info->vpadding = 0;
dsi_display->panel->host_config.line_insertion_enable = 0;
}
memcpy(&mode_info->topology, &dsi_mode->priv_info->topology,
sizeof(struct msm_display_topology));

查看文件

@@ -1652,6 +1652,12 @@ static void _sde_cp_crtc_commit_feature(struct sde_cp_node *prop_node,
struct sde_mdss_cfg *catalog = NULL;
struct sde_crtc_state *sde_crtc_state;
sde_crtc_state = to_sde_crtc_state(sde_crtc->base.state);
if (!sde_crtc_state) {
DRM_ERROR("sde_crtc_state is null\n");
return;
}
memset(&hw_cfg, 0, sizeof(hw_cfg));
_sde_cp_get_cached_payload(prop_node, &hw_cfg, &feature_enabled);
hw_cfg.num_of_mixers = sde_crtc->num_mixers;
@@ -1663,11 +1669,6 @@ static void _sde_cp_crtc_commit_feature(struct sde_cp_node *prop_node,
hw_cfg.skip_blend_plane_h = sde_crtc->skip_blend_plane_h;
hw_cfg.skip_blend_plane_w = sde_crtc->skip_blend_plane_w;
sde_crtc_state = to_sde_crtc_state(sde_crtc->base.state);
if (!sde_crtc_state) {
DRM_ERROR("invalid sde_crtc_state %pK\n", sde_crtc_state);
return;
}
hw_cfg.num_ds_enabled = sde_crtc_state->num_ds_enabled;
SDE_EVT32(hw_cfg.panel_width, hw_cfg.panel_height);

查看文件

@@ -3136,7 +3136,8 @@ static int _sde_connector_install_properties(struct drm_device *dev,
msm_property_install_enum(&c_conn->property_info, "dsc_mode", 0,
0, e_dsc_mode, ARRAY_SIZE(e_dsc_mode), 0, CONNECTOR_PROP_DSC_MODE);
if (display_info->capabilities & MSM_DISPLAY_CAP_CMD_MODE &&
if (dsi_display && dsi_display->panel &&
display_info->capabilities & MSM_DISPLAY_CAP_CMD_MODE &&
display_info->capabilities & MSM_DISPLAY_CAP_VID_MODE)
msm_property_install_enum(&c_conn->property_info,
"panel_mode", 0, 0,

查看文件

@@ -3711,7 +3711,7 @@ bool sde_crtc_is_line_insertion_supported(struct drm_crtc *crtc)
return false;
kms = _sde_crtc_get_kms(crtc);
if (!kms->catalog->has_line_insertion)
if (!kms || !kms->catalog || !kms->catalog->has_line_insertion)
return false;
list_for_each_entry(enc, &crtc->dev->mode_config.encoder_list, head) {

查看文件

@@ -1091,6 +1091,11 @@ static void _sde_encoder_phys_wb_setup_sys_cache(struct sde_encoder_phys *phys_e
return;
}
if (!hw_wb || !hw_wb->ops.setup_sys_cache) {
SDE_DEBUG("unsupported ops: setup_sys_cache WB %d\n", WBID(wb_enc));
return;
}
/*
* - use LLCC_DISP for cwb static display
* - use LLCC_DISP_1 for cwb static display read path only
@@ -1113,11 +1118,6 @@ static void _sde_encoder_phys_wb_setup_sys_cache(struct sde_encoder_phys *phys_e
return;
}
if (!hw_wb || !hw_wb->ops.setup_sys_cache) {
SDE_DEBUG("unsupported ops: setup_sys_cache WB %d\n", WBID(wb_enc));
return;
}
cache_enable = sde_connector_get_property(state, CONNECTOR_PROP_CACHE_STATE);
if (!cfg->wr_en && !cache_enable)