public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mukesh Ojha <mojha@codeaurora.org>
To: Kangjie Lu <kjlu@umn.edu>
Cc: pakki001@umn.edu, Bard Liao <bardliao@realtek.com>,
	Oder Chiou <oder_chiou@realtek.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sound: codecs: fix a potential NULL pointer dereference
Date: Mon, 25 Mar 2019 12:15:20 +0530	[thread overview]
Message-ID: <4fa0e2cb-7044-12e1-33b3-14015c94e48d@codeaurora.org> (raw)
In-Reply-To: <20190324231237.2246-1-kjlu@umn.edu>


On 3/25/2019 4:42 AM, Kangjie Lu wrote:
> In case devm_kzalloc fails, the patch returns -ENOMEM to avoid
> potential NULL pointer dereference.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
>   sound/soc/codecs/rt5663.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c
> index da6647015708..909ab99a1995 100644
> --- a/sound/soc/codecs/rt5663.c
> +++ b/sound/soc/codecs/rt5663.c
> @@ -3480,6 +3480,8 @@ static int rt5663_parse_dp(struct rt5663_priv *rt5663, struct device *dev)
>   		table_size = sizeof(struct impedance_mapping_table) *
>   			rt5663->pdata.impedance_sensing_num;
>   		rt5663->imp_table = devm_kzalloc(dev, table_size, GFP_KERNEL);
> +		if (!rt5663->imp_table)
> +			return -ENOMEM;

add checks in rt5663_parse_dp  as well.

Thanks.
Mukesh


>   		device_property_read_u32_array(dev,
>   			"realtek,impedance_sensing_table",
>   			(u32 *)rt5663->imp_table, table_size);

  reply	other threads:[~2019-03-25  6:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-24 23:12 [PATCH] sound: codecs: fix a potential NULL pointer dereference Kangjie Lu
2019-03-25  6:45 ` Mukesh Ojha [this message]
2019-03-25  6:54   ` Mukesh Ojha
2019-03-25 21:19   ` [PATCH v2] " Kangjie Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4fa0e2cb-7044-12e1-33b3-14015c94e48d@codeaurora.org \
    --to=mojha@codeaurora.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=bardliao@realtek.com \
    --cc=broonie@kernel.org \
    --cc=kjlu@umn.edu \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oder_chiou@realtek.com \
    --cc=pakki001@umn.edu \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox