linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/stm: ltdc: check memory returned by devm_kzalloc()
@ 2023-05-31  7:28 Claudiu Beznea
  2023-05-31 12:23 ` Raphael Gallais-Pou
  2024-07-15  8:33 ` Raphael Gallais-Pou
  0 siblings, 2 replies; 3+ messages in thread
From: Claudiu Beznea @ 2023-05-31  7:28 UTC (permalink / raw)
  To: yannick.fertre, raphael.gallais-pou, philippe.cornu, airlied,
	daniel, mcoquelin.stm32, alexandre.torgue
  Cc: dri-devel, linux-stm32, linux-arm-kernel, linux-kernel,
	Claudiu Beznea

devm_kzalloc() can fail and return NULL pointer. Check its return status.
Identified with Coccinelle (kmerr.cocci script).

Fixes: 484e72d3146b ("drm/stm: ltdc: add support of ycbcr pixel formats")
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---

Hi,

This has been addressed using kmerr.cocci script proposed for update
at [1].

Thank you,
Claudiu Beznea

[1] https://lore.kernel.org/all/20230530074044.1603426-1-claudiu.beznea@microchip.com/

 drivers/gpu/drm/stm/ltdc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
index 03c6becda795..9f3ac54d4cb3 100644
--- a/drivers/gpu/drm/stm/ltdc.c
+++ b/drivers/gpu/drm/stm/ltdc.c
@@ -1579,6 +1579,8 @@ static struct drm_plane *ltdc_plane_create(struct drm_device *ddev,
 			       ARRAY_SIZE(ltdc_drm_fmt_ycbcr_sp) +
 			       ARRAY_SIZE(ltdc_drm_fmt_ycbcr_fp)) *
 			       sizeof(*formats), GFP_KERNEL);
+	if (!formats)
+		return NULL;
 
 	for (i = 0; i < ldev->caps.pix_fmt_nb; i++) {
 		drm_fmt = ldev->caps.pix_fmt_drm[i];
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/stm: ltdc: check memory returned by devm_kzalloc()
  2023-05-31  7:28 [PATCH] drm/stm: ltdc: check memory returned by devm_kzalloc() Claudiu Beznea
@ 2023-05-31 12:23 ` Raphael Gallais-Pou
  2024-07-15  8:33 ` Raphael Gallais-Pou
  1 sibling, 0 replies; 3+ messages in thread
From: Raphael Gallais-Pou @ 2023-05-31 12:23 UTC (permalink / raw)
  To: Claudiu Beznea, yannick.fertre, philippe.cornu, airlied, daniel,
	mcoquelin.stm32, alexandre.torgue
  Cc: dri-devel, linux-stm32, linux-arm-kernel, linux-kernel


On 5/31/23 09:28, Claudiu Beznea wrote:
> devm_kzalloc() can fail and return NULL pointer. Check its return status.
> Identified with Coccinelle (kmerr.cocci script).
>
> Fixes: 484e72d3146b ("drm/stm: ltdc: add support of ycbcr pixel formats")
> Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
> ---
>
> Hi,
Hi Claudiu
>
> This has been addressed using kmerr.cocci script proposed for update
> at [1].
>
> Thank you,
> Claudiu Beznea
>
> [1] https://lore.kernel.org/all/20230530074044.1603426-1-claudiu.beznea@microchip.com/
>
>  drivers/gpu/drm/stm/ltdc.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
> index 03c6becda795..9f3ac54d4cb3 100644
> --- a/drivers/gpu/drm/stm/ltdc.c
> +++ b/drivers/gpu/drm/stm/ltdc.c
> @@ -1579,6 +1579,8 @@ static struct drm_plane *ltdc_plane_create(struct drm_device *ddev,
>  			       ARRAY_SIZE(ltdc_drm_fmt_ycbcr_sp) +
>  			       ARRAY_SIZE(ltdc_drm_fmt_ycbcr_fp)) *
>  			       sizeof(*formats), GFP_KERNEL);
> +	if (!formats)
> +		return NULL;
>  
>  	for (i = 0; i < ldev->caps.pix_fmt_nb; i++) {
>  		drm_fmt = ldev->caps.pix_fmt_drm[i];


Acked-by: Raphael Gallais-Pou <raphael.gallais-pou@foss.st.com>

Thanks for your patch.

Cheers,
Raphaël G.-P.


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/stm: ltdc: check memory returned by devm_kzalloc()
  2023-05-31  7:28 [PATCH] drm/stm: ltdc: check memory returned by devm_kzalloc() Claudiu Beznea
  2023-05-31 12:23 ` Raphael Gallais-Pou
@ 2024-07-15  8:33 ` Raphael Gallais-Pou
  1 sibling, 0 replies; 3+ messages in thread
From: Raphael Gallais-Pou @ 2024-07-15  8:33 UTC (permalink / raw)
  To: Claudiu Beznea, yannick.fertre, philippe.cornu, airlied, daniel,
	mcoquelin.stm32, alexandre.torgue
  Cc: dri-devel, linux-stm32, linux-arm-kernel, linux-kernel


On 5/31/23 09:28, Claudiu Beznea wrote:
> devm_kzalloc() can fail and return NULL pointer. Check its return status.
> Identified with Coccinelle (kmerr.cocci script).
>
> Fixes: 484e72d3146b ("drm/stm: ltdc: add support of ycbcr pixel formats")
> Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
> ---
>
> Hi,
>
> This has been addressed using kmerr.cocci script proposed for update
> at [1].
>
> Thank you,
> Claudiu Beznea
>
> [1] https://lore.kernel.org/all/20230530074044.1603426-1-claudiu.beznea@microchip.com/
>
Hi Claudiu,

After some delay: applied on drm-misc-next.

Thank,
Raphaël



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-07-15  8:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-31  7:28 [PATCH] drm/stm: ltdc: check memory returned by devm_kzalloc() Claudiu Beznea
2023-05-31 12:23 ` Raphael Gallais-Pou
2024-07-15  8:33 ` Raphael Gallais-Pou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).