drm/sun4i: Check return value of drm_vblank_init

drm_vblank_init can fail due to insufficient memory. Ignoring the error
and proceeding may cause the kernel to dereference an invalid pointer
when vblank is enabled.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
This commit is contained in:
Chen-Yu Tsai 2017-02-17 11:13:26 +08:00 committed by Maxime Ripard
parent 9d56defb44
commit 92b300c4e6

View File

@ -102,7 +102,11 @@ static int sun4i_drv_bind(struct device *dev)
}
drm->dev_private = drv;
drm_vblank_init(drm, 1);
/* drm_vblank_init calls kcalloc, which can fail */
ret = drm_vblank_init(drm, 1);
if (ret)
goto free_drm;
drm_mode_config_init(drm);
ret = component_bind_all(drm->dev, drm);