From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: "Sridharan, Ranjani" <ranjani.sridharan@intel.com>,
Cezary Rojewski <cezary.rojewski@intel.com>
Cc: tiwai@suse.de, Linux-ALSA <alsa-devel@alsa-project.org>,
Jaska Uimonen <jaska.uimonen@intel.com>,
Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH] ASoC: SOF: topology: use set_get_data in process load
Date: Wed, 7 Aug 2019 15:17:39 -0500 [thread overview]
Message-ID: <922d7056-8347-876f-fd2a-de17344b506e@linux.intel.com> (raw)
In-Reply-To: <CAFQqKeXnSFUDG_72LGhxMD5aAU-DjnnPc9oqcrWBy_NfJNRQLg@mail.gmail.com>
On 8/7/19 3:09 PM, Sridharan, Ranjani wrote:
>
>
> On Wed, Aug 7, 2019 at 12:32 PM Cezary Rojewski
> <cezary.rojewski@intel.com <mailto:cezary.rojewski@intel.com>> wrote:
>
> On 2019-08-07 16:52, Pierre-Louis Bossart wrote:
> > From: Jaska Uimonen <jaska.uimonen@intel.com
> <mailto:jaska.uimonen@intel.com>>
>
> > process = kzalloc(ipc_size, GFP_KERNEL);
> > - if (!process)
> > + if (!process) {
> > + kfree(wdata);
> > return -ENOMEM;
> > + }
> >
> > /* configure iir IPC message */
> > process->comp.hdr.size = ipc_size;
> > @@ -1835,7 +1890,9 @@ static int sof_process_load(struct
> snd_soc_component *scomp, int index,
> > if (ret != 0) {
> > dev_err(sdev->dev, "error: parse process.cfg tokens
> failed %d\n",
> > le32_to_cpu(private->size));
> > - goto err;
> > + kfree(wdata);
> > + kfree(process);
> > + return ret;
> > }
> >
>
> > @@ -1886,10 +1916,36 @@ static int sof_process_load(struct
> snd_soc_component *scomp, int index,
> >
> > ret = sof_ipc_tx_message(sdev->ipc, process->comp.hdr.cmd,
> process,
> > ipc_size, r, sizeof(*r));
> > - if (ret >= 0)
> > +
> > + if (ret < 0) {
> > + dev_err(sdev->dev, "error: create process failed\n");
> > + kfree(wdata);
> > + kfree(process);
> > return ret;
> > -err:
> > - kfree(process);
> > + }
> > +
> > + /* we sent the data in single message so return */
> > + if (ipc_data_size) {
> > + kfree(wdata);
> > + return ret;
> > + }
> > +
> > + /* send control data with large message supported method */
> > + for (i = 0; i < widget->num_kcontrols; i++) {
> > + wdata[i].control->readback_offset = 0;
> > + ret = snd_sof_ipc_set_get_comp_data(sdev->ipc,
> wdata[i].control,
> > + wdata[i].ipc_cmd,
> > + wdata[i].ctrl_type,
> > +
> wdata[i].control->cmd,
> > + true);
> > + if (ret != 0) {
> > + dev_err(sdev->dev, "error: send control
> failed\n");
> > + kfree(process);
> > + break;
> > + }
> > + }
> > +
> > + kfree(wdata);
> > return ret;
> > }
>
> On several occasions you've added individual error paths instead of a
> unified one. Personally I don't find it easier to read and understand
> function's flow at all.
>
> <ifs with goto err>
>
> err:
> kfree(process);
> kfree(wdata);
> return ret;
>
> doesn't look that bad..
>
> Thanks for pointing out. Perhaps, the error handling can be improved a
> little. We can fix in v2.
I took a look at this and there's really only 2/3 places where we could
use a goto, but we'd have to use 2 labels depending on whether we free
process/wdata so not sure if we'd make the code more self-explanatory in
the end.
Jaska, can you take a look?
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
prev parent reply other threads:[~2019-08-07 20:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-07 14:52 [PATCH] ASoC: SOF: topology: use set_get_data in process load Pierre-Louis Bossart
2019-08-07 19:30 ` Cezary Rojewski
2019-08-07 20:09 ` Sridharan, Ranjani
2019-08-07 20:17 ` 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=922d7056-8347-876f-fd2a-de17344b506e@linux.intel.com \
--to=pierre-louis.bossart@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=cezary.rojewski@intel.com \
--cc=jaska.uimonen@intel.com \
--cc=ranjani.sridharan@intel.com \
--cc=tiwai@suse.de \
/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