linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: i2c: tvp5150: check return value of devm_kasprintf()
@ 2023-06-15 10:30 Claudiu Beznea
  2023-06-16 12:23 ` Marco Felsch
  0 siblings, 1 reply; 2+ messages in thread
From: Claudiu Beznea @ 2023-06-15 10:30 UTC (permalink / raw)
  To: mchehab, hverkuil-cisco, olteanv, javierm, sakari.ailus,
	srinivas.pandruvada, u.kleine-koenig, laurent.pinchart, m.felsch
  Cc: linux-media, linux-kernel, Claudiu Beznea

devm_kasprintf() returns a pointer to dynamically allocated memory.
Pointer could be NULL in case allocation fails. Check pointer validity.
Identified with coccinelle (kmerr.cocci script).

Fixes: 0556f1d580d4 ("media: tvp5150: add input source selection of_graph support")
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/media/i2c/tvp5150.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index 859f1cb2fa74..84f87c016f9b 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -2068,6 +2068,10 @@ static int tvp5150_parse_dt(struct tvp5150 *decoder, struct device_node *np)
 		tvpc->ent.name = devm_kasprintf(dev, GFP_KERNEL, "%s %s",
 						v4l2c->name, v4l2c->label ?
 						v4l2c->label : "");
+		if (!tvpc->ent.name) {
+			ret = -ENOMEM;
+			goto err_free;
+		}
 	}
 
 	ep_np = of_graph_get_endpoint_by_regs(np, TVP5150_PAD_VID_OUT, 0);
-- 
2.34.1


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

* Re: [PATCH] media: i2c: tvp5150: check return value of devm_kasprintf()
  2023-06-15 10:30 [PATCH] media: i2c: tvp5150: check return value of devm_kasprintf() Claudiu Beznea
@ 2023-06-16 12:23 ` Marco Felsch
  0 siblings, 0 replies; 2+ messages in thread
From: Marco Felsch @ 2023-06-16 12:23 UTC (permalink / raw)
  To: Claudiu Beznea
  Cc: mchehab, hverkuil-cisco, olteanv, javierm, sakari.ailus,
	srinivas.pandruvada, u.kleine-koenig, laurent.pinchart,
	linux-media, linux-kernel

Hi,

On 23-06-15, Claudiu Beznea wrote:
> devm_kasprintf() returns a pointer to dynamically allocated memory.
> Pointer could be NULL in case allocation fails. Check pointer validity.
> Identified with coccinelle (kmerr.cocci script).

lgtm

> Fixes: 0556f1d580d4 ("media: tvp5150: add input source selection of_graph support")
> Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>

Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>

> ---
> 
> 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/media/i2c/tvp5150.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
> index 859f1cb2fa74..84f87c016f9b 100644
> --- a/drivers/media/i2c/tvp5150.c
> +++ b/drivers/media/i2c/tvp5150.c
> @@ -2068,6 +2068,10 @@ static int tvp5150_parse_dt(struct tvp5150 *decoder, struct device_node *np)
>  		tvpc->ent.name = devm_kasprintf(dev, GFP_KERNEL, "%s %s",
>  						v4l2c->name, v4l2c->label ?
>  						v4l2c->label : "");
> +		if (!tvpc->ent.name) {
> +			ret = -ENOMEM;
> +			goto err_free;
> +		}
>  	}
>  
>  	ep_np = of_graph_get_endpoint_by_regs(np, TVP5150_PAD_VID_OUT, 0);
> -- 
> 2.34.1
> 
> 

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

end of thread, other threads:[~2023-06-16 12:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-15 10:30 [PATCH] media: i2c: tvp5150: check return value of devm_kasprintf() Claudiu Beznea
2023-06-16 12:23 ` Marco Felsch

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).