2015-02-12 09:09:15

by Kiran Padwal

[permalink] [raw]
Subject: [PATCH] ASoC: omap-hdmi-audio: Add missing error check for devm_kzalloc

This patch add a missing check on the return value of devm_kzalloc,
which would cause a NULL pointer dereference in a OOM situation.

Signed-off-by: Kiran Padwal <[email protected]>
---
sound/soc/omap/omap-hdmi-audio.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/sound/soc/omap/omap-hdmi-audio.c b/sound/soc/omap/omap-hdmi-audio.c
index ccfb41c..f7eb42a 100644
--- a/sound/soc/omap/omap-hdmi-audio.c
+++ b/sound/soc/omap/omap-hdmi-audio.c
@@ -352,6 +352,9 @@ static int omap_hdmi_audio_probe(struct platform_device *pdev)
return ret;

card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
+ if (!card)
+ return -ENOMEM;
+
card->name = devm_kasprintf(dev, GFP_KERNEL,
"HDMI %s", dev_name(ad->dssdev));
card->owner = THIS_MODULE;
--
1.7.9.5


2015-02-12 09:23:08

by Peter Ujfalusi

[permalink] [raw]
Subject: Re: [PATCH] ASoC: omap-hdmi-audio: Add missing error check for devm_kzalloc

On 02/12/2015 11:08 AM, Kiran Padwal wrote:
> This patch add a missing check on the return value of devm_kzalloc,
> which would cause a NULL pointer dereference in a OOM situation.

Acked-by: Peter Ujfalusi <[email protected]>

>
> Signed-off-by: Kiran Padwal <[email protected]>
> ---
> sound/soc/omap/omap-hdmi-audio.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/sound/soc/omap/omap-hdmi-audio.c b/sound/soc/omap/omap-hdmi-audio.c
> index ccfb41c..f7eb42a 100644
> --- a/sound/soc/omap/omap-hdmi-audio.c
> +++ b/sound/soc/omap/omap-hdmi-audio.c
> @@ -352,6 +352,9 @@ static int omap_hdmi_audio_probe(struct platform_device *pdev)
> return ret;
>
> card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
> + if (!card)
> + return -ENOMEM;
> +
> card->name = devm_kasprintf(dev, GFP_KERNEL,
> "HDMI %s", dev_name(ad->dssdev));
> card->owner = THIS_MODULE;
>


--
P?ter

2015-02-14 04:34:08

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] ASoC: omap-hdmi-audio: Add missing error check for devm_kzalloc

On Thu, Feb 12, 2015 at 02:38:02PM +0530, Kiran Padwal wrote:
> This patch add a missing check on the return value of devm_kzalloc,
> which would cause a NULL pointer dereference in a OOM situation.

Applied, thanks.


Attachments:
(No filename) (217.00 B)
signature.asc (473.00 B)
Digital signature
Download all attachments