drm/mediatek: check for memory allocation failure
authorChristophe Jaillet <christophe.jaillet@wanadoo.fr>
Fri, 9 Jun 2017 19:27:12 +0000 (21:27 +0200)
committerCK Hu <ck.hu@mediatek.com>
Tue, 27 Jun 2017 09:34:53 +0000 (17:34 +0800)
If 'devm_kmalloc_array' returns NULL, we should return -ENOMEM as already
done a few lines above instead of deferencing a NULL pointer a few lines
below.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
Signed-off-by: CK Hu <ck.hu@mediatek.com>
drivers/gpu/drm/mediatek/mtk_drm_crtc.c

index 6582e1f56d37cfb23bcf54a740ddf22a207c7ded..cb32c9369f3a6259914898bcc6817bc9d2fd0e99 100644 (file)
@@ -559,6 +559,8 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
        mtk_crtc->ddp_comp = devm_kmalloc_array(dev, mtk_crtc->ddp_comp_nr,
                                                sizeof(*mtk_crtc->ddp_comp),
                                                GFP_KERNEL);
+       if (!mtk_crtc->ddp_comp)
+               return -ENOMEM;
 
        mtk_crtc->mutex = mtk_disp_mutex_get(priv->mutex_dev, pipe);
        if (IS_ERR(mtk_crtc->mutex)) {