mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] media: video-mux: fix  null pointer dereferences
@ 2019-03-09  7:20 Kangjie Lu
  2019-03-11  9:18 ` Philipp Zabel
  0 siblings, 1 reply; 2+ messages in thread
From: Kangjie Lu @ 2019-03-09  7:20 UTC (permalink / raw)
  To: kjlu
  Cc: pakki001, Philipp Zabel, Mauro Carvalho Chehab, linux-media,
	linux-kernel

devm_kcalloc may fail and return a null pointer. The fix returns
-ENOMEM upon failures to avoid null pointer dereferences.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 drivers/media/platform/video-mux.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/media/platform/video-mux.c b/drivers/media/platform/video-mux.c
index c33900e3c23e..4135165cdabe 100644
--- a/drivers/media/platform/video-mux.c
+++ b/drivers/media/platform/video-mux.c
@@ -399,9 +399,14 @@ static int video_mux_probe(struct platform_device *pdev)
 	vmux->active = -1;
 	vmux->pads = devm_kcalloc(dev, num_pads, sizeof(*vmux->pads),
 				  GFP_KERNEL);
+	if (!vmux->pads)
+		return -ENOMEM;
+
 	vmux->format_mbus = devm_kcalloc(dev, num_pads,
 					 sizeof(*vmux->format_mbus),
 					 GFP_KERNEL);
+	if (!vmux->format_mbus)
+		return -ENOMEM;
 
 	for (i = 0; i < num_pads; i++) {
 		vmux->pads[i].flags = (i < num_pads - 1) ? MEDIA_PAD_FL_SINK
-- 
2.17.1


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

* Re: [PATCH] media: video-mux: fix  null pointer dereferences
  2019-03-09  7:20 [PATCH] media: video-mux: fix null pointer dereferences Kangjie Lu
@ 2019-03-11  9:18 ` Philipp Zabel
  0 siblings, 0 replies; 2+ messages in thread
From: Philipp Zabel @ 2019-03-11  9:18 UTC (permalink / raw)
  To: Kangjie Lu; +Cc: pakki001, Mauro Carvalho Chehab, linux-media, linux-kernel

On Sat, 2019-03-09 at 01:20 -0600, Kangjie Lu wrote:
> devm_kcalloc may fail and return a null pointer. The fix returns
> -ENOMEM upon failures to avoid null pointer dereferences.
> 
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
>  drivers/media/platform/video-mux.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/media/platform/video-mux.c b/drivers/media/platform/video-mux.c
> index c33900e3c23e..4135165cdabe 100644
> --- a/drivers/media/platform/video-mux.c
> +++ b/drivers/media/platform/video-mux.c
> @@ -399,9 +399,14 @@ static int video_mux_probe(struct platform_device *pdev)
>  	vmux->active = -1;
>  	vmux->pads = devm_kcalloc(dev, num_pads, sizeof(*vmux->pads),
>  				  GFP_KERNEL);
> +	if (!vmux->pads)
> +		return -ENOMEM;
> +
>  	vmux->format_mbus = devm_kcalloc(dev, num_pads,
>  					 sizeof(*vmux->format_mbus),
>  					 GFP_KERNEL);
> +	if (!vmux->format_mbus)
> +		return -ENOMEM;
>  
>  	for (i = 0; i < num_pads; i++) {
>  		vmux->pads[i].flags = (i < num_pads - 1) ? MEDIA_PAD_FL_SINK

Thank you,
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>

regards
Philipp

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

end of thread, other threads:[~2019-03-11  9:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-09  7:20 [PATCH] media: video-mux: fix null pointer dereferences Kangjie Lu
2019-03-11  9:18 ` Philipp Zabel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®