From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Cezary Rojewski <cezary.rojewski@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jie Yang <yang.jie@linux.intel.com>,
ALSA Development Mailing List <alsa-devel@alsa-project.org>,
Navid Emamdoost <navid.emamdoost@gmail.com>,
Takashi Iwai <tiwai@suse.com>,
Liam Girdwood <liam.r.girdwood@linux.intel.com>,
Mark Brown <broonie@kernel.org>,
Stephen McCamant <smccaman@umn.edu>, Kangjie Lu <kjlu@umn.edu>,
Thomas Gleixner <tglx@linutronix.de>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Enrico Weigelt <info@metux.net>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Navid Emamdoost <emamd001@umn.edu>
Subject: Re: [alsa-devel] [PATCH v2] ASoC: Intel: Skylake: prevent memory leak in snd_skl_parse_uuids
Date: Fri, 27 Sep 2019 17:25:41 -0500 [thread overview]
Message-ID: <3428d5e2-3246-7e1c-cb4d-59351193e4de@linux.intel.com> (raw)
In-Reply-To: <CAHp75Veung3v41RMmBoQHE7TFWUccE2oXsVnNgUt0JE0naTfLw@mail.gmail.com>
On 9/27/19 3:39 PM, Andy Shevchenko wrote:
> On Fri, Sep 27, 2019 at 7:39 PM Pierre-Louis Bossart
> <pierre-louis.bossart@linux.intel.com> wrote:
>>> The problem with solution #1 is freeing orphaned pointer. It will work,
>>> but it's simple is not okay from object life time prospective.
>>
>> ?? I don't get your point at all Andy.
>> Two allocations happens in a loop and if the second fails, you free the
>> first and then jump to free everything allocated in the previous
>> iterations. what am I missing?
>
> Two things:
> - one allocation is done with kzalloc(), while the other one with
> devm_kcalloc()
> - due to above the ordering of resources is reversed
Ah yes, I see your point now, sorry for being thick.
Indeed it'd make sense to use devm_ for both allocations, but then the
kfree needs to be removed in the error handling.
prev parent reply other threads:[~2019-09-27 22:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-25 16:19 [PATCH v2] ASoC: Intel: Skylake: prevent memory leak in snd_skl_parse_uuids Navid Emamdoost
2019-09-25 17:05 ` Pierre-Louis Bossart
2019-09-27 2:55 ` Navid Emamdoost
2019-09-27 13:14 ` Pierre-Louis Bossart
2019-09-27 15:10 ` Cezary Rojewski
2019-09-27 15:33 ` Andy Shevchenko
2019-09-27 16:37 ` [alsa-devel] " Pierre-Louis Bossart
2019-09-27 20:39 ` Andy Shevchenko
2019-09-27 22:25 ` Pierre-Louis Bossart [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=3428d5e2-3246-7e1c-cb4d-59351193e4de@linux.intel.com \
--to=pierre-louis.bossart@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=andy.shevchenko@gmail.com \
--cc=broonie@kernel.org \
--cc=cezary.rojewski@intel.com \
--cc=emamd001@umn.edu \
--cc=gregkh@linuxfoundation.org \
--cc=info@metux.net \
--cc=kjlu@umn.edu \
--cc=liam.r.girdwood@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=navid.emamdoost@gmail.com \
--cc=smccaman@umn.edu \
--cc=tglx@linutronix.de \
--cc=tiwai@suse.com \
--cc=yang.jie@linux.intel.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;
as well as URLs for NNTP newsgroup(s).