From: Peter Rosin <peda@axentia.se>
To: Mark Brown <broonie@kernel.org>, Peter Rosin <peda@lysator.liu.se>
Cc: "alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
Liam Girdwood <lgirdwood@gmail.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] ASoC: Augment existing card DAPM routes in snd_soc_of_parse_audio_routing
Date: Fri, 28 Nov 2014 16:11:13 +0000 [thread overview]
Message-ID: <c837f8c59be24429aeed270636aac570@EMAIL.axentia.se> (raw)
In-Reply-To: <20141128160320.GY7712@sirena.org.uk>
Mark Brown wrote:
> On Thu, Nov 27, 2014 at 10:02:42PM +0100, Peter Rosin wrote:
>
> > - routes = devm_kzalloc(card->dev, num_routes * sizeof(*routes),
> > + old_routes = card->num_dapm_routes;
> > + routes = devm_kzalloc(card->dev,
> > + (old_routes + num_routes) * sizeof(*routes),
> > GFP_KERNEL);
> > if (!routes) {
> > dev_err(card->dev,
> > @@ -4611,9 +4613,11 @@ int snd_soc_of_parse_audio_routing(struct
> snd_soc_card *card,
> > return -EINVAL;
> > }
> >
> > + memcpy(routes, card->dapm_routes, old_routes * sizeof(*routes));
> > +
>
> Aren't we open coding krealloc() here?
I don't think krealloc() is appropriate since we don't know where the memory
comes from. The typical use I see is that the card struct is initialized as:
static const struct snd_soc_dapm_route foo_intercon[] = {
{ "MUX1", "Loop", "IN1" },
{ "MUX1", "Mixer", "MIX1" },
{ "MIX1", NULL, "DAC" },
{ "MIX1", "IN1 Switch", "IN1" },
{ "Line Out Jack", NULL, "MUX1" },
};
static struct snd_soc_card foo_card = {
.name = "foo",
.owner = THIS_MODULE,
.dapm_routes = foo_intercon,
.num_dapm_routes = ARRAY_SIZE(foo_intercon),
/* etc */
};
If that's the case, krealloc() seems dead wrong. On the other hand, if
snd_soc_of_parse_audio_routing() were to be called many times, a lot
of devm_kzalloc()ed memory would be kept dangling. I don't expect a card
to call snd_soc_of_parse_audio_routing() more than once though...
Cheers,
Peter
next prev parent reply other threads:[~2014-11-28 16:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-27 21:02 Peter Rosin
2014-11-28 16:03 ` Mark Brown
2014-11-28 16:11 ` Peter Rosin [this message]
2014-12-04 22:40 ` Mark Brown
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=c837f8c59be24429aeed270636aac570@EMAIL.axentia.se \
--to=peda@axentia.se \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peda@lysator.liu.se \
/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®