Alsa-Devel Archive on lore.kernel.org
 help / color / Atom feed
From: <wen.yang99@zte.com.cn>
To: Markus.Elfring@web.de
Cc: wang.yi59@zte.com.cn, alsa-devel@alsa-project.org,
	xue.zhihong@zte.com.cn, lgirdwood@gmail.com, sbkim73@samsung.com,
	tiwai@suse.com, kernel-janitors@vger.kernel.org,
	linux-kernel@vger.kernel.org, krzk@kernel.org,
	broonie@kernel.org, s.nawrocki@samsung.com,
	cheng.shengyu@zte.com.cn
Subject: Re: [2/2] ASoC: samsung: odroid: fix a double-free issue for cpu_dai
Date: Mon, 15 Jul 2019 09:49:13 +0800 (CST)
Message-ID: <201907150949139435825@zte.com.cn> (raw)
In-Reply-To: <4545ce50-493c-8faa-fdcd-5aee3ca30792@web.de>

> > The cpu_dai variable is still being used after the of_node_put() call,
> 
> Such an implementation detail is questionable.
> https://wiki.sei.cmu.edu/confluence/display/c/MEM30-C.+Do+not+access+freed+memory
> 
> 
> > which may result in double-free:
> 
> This consequence is also undesirable.
> https://cwe.mitre.org/data/definitions/415.html
> 
> 
> Now I wonder if two update steps are really appropriate as a fix
> instead of using a single update step for the desired correction
> in this software module.
> Should a commit (including previous ones) usually be correct by itself?

Thanks.
These two updates fix two different bugs.

One of them is the use-after-free issue introduced by bc3cf17b575a:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=bc3cf17b575a7a97b4af7ddcf86133175da7a582

-       ret = snd_soc_of_get_dai_link_codecs(dev, codec, link);
+       cpu_dai = of_parse_phandle(cpu, "sound-dai", 0);
+       of_node_put(cpu);
+       of_node_put(codec);
+
+       ret = snd_soc_of_get_dai_link_codecs(dev, codec, codec_link);
        if (ret < 0)
                goto err_put_codec_n;

and the other is the double-free issue introduced by d832d2b246c5:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/sound/soc/samsung/odroid.c?id=d832d2b246c516eacb2d0ba53ec17ed59c3cd62b#n318
and n303, n308.

So we sent two patches to fix them separately.

--
Regards,
Wen

  reply index

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-13  3:46 [PATCH 0/2] ASoC: samsung: odroid: fix err handling of odroid_audio_probe Wen Yang
2019-07-13  3:46 ` [PATCH 1/2] ASoC: samsung: odroid: fix an use-after-free issue for codec Wen Yang
2019-07-14  8:47   ` Markus Elfring
2019-07-14 10:55   ` [1/2] " Markus Elfring
2019-07-16  9:06   ` [PATCH 1/2] " Krzysztof Kozlowski
2019-07-16 18:18   ` Applied "ASoC: samsung: odroid: fix an use-after-free issue for codec" to the asoc tree Mark Brown
2019-07-13  3:46 ` [PATCH 2/2] ASoC: samsung: odroid: fix a double-free issue for cpu_dai Wen Yang
2019-07-14 12:47   ` [2/2] " Markus Elfring
2019-07-15  1:49     ` wen.yang99 [this message]
2019-07-15  6:40       ` [alsa-devel] " Markus Elfring
2019-07-16  9:06   ` [PATCH 2/2] " Krzysztof Kozlowski
2019-07-16 18:18   ` Applied "ASoC: samsung: odroid: fix a double-free issue for cpu_dai" to the asoc tree Mark Brown
2019-07-14 10:07 ` [PATCH 0/2] ASoC: samsung: odroid: fix err handling of odroid_audio_probe Markus Elfring

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=201907150949139435825@zte.com.cn \
    --to=wen.yang99@zte.com.cn \
    --cc=Markus.Elfring@web.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=cheng.shengyu@zte.com.cn \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=krzk@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=s.nawrocki@samsung.com \
    --cc=sbkim73@samsung.com \
    --cc=tiwai@suse.com \
    --cc=wang.yi59@zte.com.cn \
    --cc=xue.zhihong@zte.com.cn \
    /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

Alsa-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/alsa-devel/0 alsa-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 alsa-devel alsa-devel/ https://lore.kernel.org/alsa-devel \
		alsa-devel@alsa-project.org
	public-inbox-index alsa-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.alsa-project.alsa-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git