Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1662706 > unrolled thread

[PATCH] drm/mediatek: check for memory allocation failure

Started byChristophe JAILLET <christophe.jaillet@wanadoo.fr>
First post2017-06-09 21:30 +0200
Last post2017-06-13 09:50 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] drm/mediatek: check for memory allocation failure Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2017-06-09 21:30 +0200
    Re: [PATCH] drm/mediatek: check for memory allocation failure Matthias Brugger <matthias.bgg@gmail.com> - 2017-06-12 11:10 +0200
    Re: [PATCH] drm/mediatek: check for memory allocation failure CK Hu <ck.hu@mediatek.com> - 2017-06-13 09:50 +0200

#1662706 — [PATCH] drm/mediatek: check for memory allocation failure

FromChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Date2017-06-09 21:30 +0200
Subject[PATCH] drm/mediatek: check for memory allocation failure
Message-ID<tQxLA-5xN-7@gated-at.bofh.it>
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>
---
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index 6582e1f56d37..cb32c9369f3a 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -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)) {
-- 
2.11.0

[toc] | [next] | [standalone]


#1663339

FromMatthias Brugger <matthias.bgg@gmail.com>
Date2017-06-12 11:10 +0200
Message-ID<tRtwd-ch-1@gated-at.bofh.it>
In reply to#1662706

On 09/06/17 21:27, Christophe JAILLET wrote:
> 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>

>   drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index 6582e1f56d37..cb32c9369f3a 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -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)) {
> 

[toc] | [prev] | [next] | [standalone]


#1664565

FromCK Hu <ck.hu@mediatek.com>
Date2017-06-13 09:50 +0200
Message-ID<tROKm-59U-17@gated-at.bofh.it>
In reply to#1662706
Hi, Christophe:

Applied to my branch mediatek-drm-next-4.13, thanks.

Regards,
CK

On Fri, 2017-06-09 at 21:27 +0200, Christophe JAILLET wrote:
> 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>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index 6582e1f56d37..cb32c9369f3a 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -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)) {

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web