From: Takashi Iwai <tiwai@suse.de>
To: Dinghao Liu <dinghao.liu@zju.edu.cn>
Cc: kjlu@umn.edu, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
Arnd Bergmann <arnd@arndb.de>,
alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ALSA: opti9xx: Fix memleak in snd_opti9xx_read_check
Date: Mon, 31 Aug 2020 11:48:30 +0200 [thread overview]
Message-ID: <s5ho8mri1sh.wl-tiwai@suse.de> (raw)
In-Reply-To: <20200829080517.22182-1-dinghao.liu@zju.edu.cn>
On Sat, 29 Aug 2020 10:05:15 +0200,
Dinghao Liu wrote:
>
> When request_region() on chip->res_mc_indir fails,
> chip->res_mc_base should be freed to prevent memleak.
>
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
The resources are freed automatically at private_free callback
(snd_card_opti9xx_free()) called via snd_card_free() in the error
path, hence this patch would lead to double-free.
thanks,
Takashi
> ---
> sound/isa/opti9xx/opti92x-ad1848.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c
> index 881d3b5711d2..06ba18d1737c 100644
> --- a/sound/isa/opti9xx/opti92x-ad1848.c
> +++ b/sound/isa/opti9xx/opti92x-ad1848.c
> @@ -679,8 +679,11 @@ static int snd_opti9xx_read_check(struct snd_opti9xx *chip)
> #else /* OPTi93X */
> chip->res_mc_indir = request_region(chip->mc_indir_index, 2,
> "OPTi93x MC");
> - if (chip->res_mc_indir == NULL)
> + if (chip->res_mc_indir == NULL) {
> + release_and_free_resource(chip->res_mc_base);
> + chip->res_mc_base = NULL;
> return -EBUSY;
> + }
>
> spin_lock_irqsave(&chip->lock, flags);
> outb(chip->password, chip->mc_base + chip->pwd_reg);
> --
> 2.17.1
>
prev parent reply other threads:[~2020-08-31 9:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-29 8:05 Dinghao Liu
2020-08-31 9:48 ` Takashi Iwai [this message]
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=s5ho8mri1sh.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=arnd@arndb.de \
--cc=dinghao.liu@zju.edu.cn \
--cc=gustavoars@kernel.org \
--cc=kjlu@umn.edu \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®