drm/rockchip: fix some warning from smatch check
drivers/gpu/drm/rockchip/rockchip_drm_drv.c:489 update_state() warn: variable dereferenced before check 'encoder' (see line 488) drivers/gpu/drm/rockchip/rockchip_drm_drv.c:687 rockchip_register_crtc_funcs() error: buffer overflow 'priv->crtc_funcs' 2 <= 2 drivers/gpu/drm/rockchip/rockchip_drm_drv.c:700 rockchip_unregister_crtc_funcs() error: buffer overflow 'priv->crtc_funcs' 2 <= 2 drivers/gpu/drm/rockchip/rockchip_drm_rga.c:848 rga_probe() warn: passing zero to 'PTR_ERR' drivers/gpu/drm/rockchip/rockchip_drm_vop.c:597 vop_csc_setup() warn: variable dereferenced before check 'y2r_table' (see line 578) drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1059 vop_plane_atomic_update() warn: variable dereferenced before check 'crtc' (see line 1041) drivers/gpu/drm/rockchip/rockchip_lvds.c:88 lvds_name_to_format() error: strncmp() '"vesa"' too small (5 vs 6) I don't konw how to fix following error, maybe rga owner can fix it. drivers/gpu/drm/rockchip/rockchip_drm_rga.c:174 rga_alloc_dma_buf_for_cmdlist() error: buffer overflow 'cmdlist->data' 64 <= 64 Change-Id: I41cd098dbd2f311d01b4e84cf0d51598264c8e31 Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
This commit is contained in:
@@ -485,8 +485,10 @@ static int update_state(struct drm_device *drm_dev,
|
||||
!connector_helper_funcs->best_encoder)
|
||||
return -ENXIO;
|
||||
encoder = connector_helper_funcs->best_encoder(connector);
|
||||
if (!encoder)
|
||||
return -ENXIO;
|
||||
encoder_helper_funcs = encoder->helper_private;
|
||||
if (!encoder || !encoder_helper_funcs->atomic_check)
|
||||
if (!encoder_helper_funcs->atomic_check)
|
||||
return -ENXIO;
|
||||
ret = encoder_helper_funcs->atomic_check(encoder, crtc->state,
|
||||
conn_state);
|
||||
@@ -681,7 +683,7 @@ int rockchip_register_crtc_funcs(struct drm_crtc *crtc,
|
||||
int pipe = drm_crtc_index(crtc);
|
||||
struct rockchip_drm_private *priv = crtc->dev->dev_private;
|
||||
|
||||
if (pipe > ROCKCHIP_MAX_CRTC)
|
||||
if (pipe >= ROCKCHIP_MAX_CRTC)
|
||||
return -EINVAL;
|
||||
|
||||
priv->crtc_funcs[pipe] = crtc_funcs;
|
||||
@@ -694,7 +696,7 @@ void rockchip_unregister_crtc_funcs(struct drm_crtc *crtc)
|
||||
int pipe = drm_crtc_index(crtc);
|
||||
struct rockchip_drm_private *priv = crtc->dev->dev_private;
|
||||
|
||||
if (pipe > ROCKCHIP_MAX_CRTC)
|
||||
if (pipe >= ROCKCHIP_MAX_CRTC)
|
||||
return;
|
||||
|
||||
priv->crtc_funcs[pipe] = NULL;
|
||||
|
||||
@@ -845,7 +845,7 @@ static int rga_probe(struct platform_device *pdev)
|
||||
rga->rga_workq = create_singlethread_workqueue("rga");
|
||||
if (!rga->rga_workq) {
|
||||
dev_err(rga->dev, "failed to create workqueue\n");
|
||||
ret = PTR_ERR(rga->rga_workq);
|
||||
ret = -ENOMEM;
|
||||
goto err_destroy_slab;
|
||||
}
|
||||
|
||||
|
||||
@@ -594,14 +594,13 @@ static int vop_csc_setup(const struct vop_csc_table *csc_table,
|
||||
*y2r_table = csc_table->y2r_bt2020;
|
||||
if (input_csc == CSC_BT2020)
|
||||
*r2r_table = csc_table->r2r_bt2020_to_bt709;
|
||||
if (!is_input_yuv || y2r_table) {
|
||||
if (!is_input_yuv || *y2r_table) {
|
||||
if (output_csc == CSC_BT709)
|
||||
*r2y_table = csc_table->r2y_bt709;
|
||||
else
|
||||
*r2y_table = csc_table->r2y_bt601;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!is_input_yuv)
|
||||
return 0;
|
||||
@@ -1034,8 +1033,8 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
|
||||
struct drm_crtc *crtc = state->crtc;
|
||||
struct vop_win *win = to_vop_win(plane);
|
||||
struct vop_plane_state *vop_plane_state = to_vop_plane_state(state);
|
||||
struct rockchip_crtc_state *s = to_rockchip_crtc_state(crtc->state);
|
||||
struct vop *vop = to_vop(state->crtc);
|
||||
struct rockchip_crtc_state *s;
|
||||
struct vop *vop;
|
||||
struct drm_framebuffer *fb = state->fb;
|
||||
unsigned int actual_w, actual_h;
|
||||
unsigned int dsp_stx, dsp_sty;
|
||||
@@ -1074,6 +1073,9 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
|
||||
ymirror = !!(state->rotation & BIT(DRM_REFLECT_Y));
|
||||
xmirror = !!(state->rotation & BIT(DRM_REFLECT_X));
|
||||
|
||||
vop = to_vop(state->crtc);
|
||||
s = to_rockchip_crtc_state(crtc->state);
|
||||
|
||||
spin_lock(&vop->reg_lock);
|
||||
|
||||
VOP_WIN_SET(vop, win, xmirror, xmirror);
|
||||
|
||||
@@ -85,7 +85,7 @@ static inline int lvds_name_to_format(const char *s)
|
||||
|
||||
if (strncmp(s, "jeida", 6) == 0)
|
||||
return LVDS_FORMAT_JEIDA;
|
||||
else if (strncmp(s, "vesa", 6) == 0)
|
||||
else if (strncmp(s, "vesa", 5) == 0)
|
||||
return LVDS_FORMAT_VESA;
|
||||
|
||||
return -EINVAL;
|
||||
|
||||
Reference in New Issue
Block a user