From: Takashi Iwai <tiwai@suse.de>
To: Jesper Juhl <jj@chaosbits.net>
Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org,
Joe Perches <joe@perches.com>,
Eliot Blennerhassett <eblennerhassett@audioscience.com>,
Jaroslav Kysela <perex@perex.cz>,
support@audioscience.com
Subject: Re: [PATCH] Sound: AudioScience HPI: Don't leak firmware if mem alloc fails
Date: Fri, 29 Jul 2011 07:36:50 +0200 [thread overview]
Message-ID: <s5hpqkt6425.wl%tiwai@suse.de> (raw)
In-Reply-To: <alpine.LNX.2.00.1107282145230.20477@swampdragon.chaosbits.net>
At Thu, 28 Jul 2011 21:48:27 +0200 (CEST),
Jesper Juhl wrote:
>
> We leak the memory allocated to 'firmware' when we fail to
> release_firmware() after a kmalloc() failure in hpi_dsp_code_open().
> This patch should take care of the leak.
>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
> sound/pci/asihpi/hpidspcd.c | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
>
> Build tested only.
>
> diff --git a/sound/pci/asihpi/hpidspcd.c b/sound/pci/asihpi/hpidspcd.c
> index 3a7afa3..8d261ef 100644
> --- a/sound/pci/asihpi/hpidspcd.c
> +++ b/sound/pci/asihpi/hpidspcd.c
> @@ -85,8 +85,10 @@ short hpi_dsp_code_open(u32 adapter, void *os_data, struct dsp_code *dsp_code,
>
> HPI_DEBUG_LOG(DEBUG, "dsp code %s opened\n", fw_name);
> dsp_code->pvt = kmalloc(sizeof(*dsp_code->pvt), GFP_KERNEL);
> - if (!dsp_code->pvt)
> + if (!dsp_code->pvt) {
> + release_firmware(firmware);
> return HPI_ERROR_MEMORY_ALLOC;
> + }
IMO, it's better to use the same error handling like others, i.e.
"goto error2". But you want to pass a different error code, so we'd
need to introduce an error code variable there...
Takashi
next prev parent reply other threads:[~2011-07-29 5:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-28 19:48 Jesper Juhl
2011-07-29 5:36 ` Takashi Iwai [this message]
2011-07-29 9:07 ` Jesper Juhl
2011-07-31 21:16 ` Jesper Juhl
2011-08-01 9:04 ` Takashi Iwai
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=s5hpqkt6425.wl%tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=eblennerhassett@audioscience.com \
--cc=jj@chaosbits.net \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=support@audioscience.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®