alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Mengdong Lin <mengdong.lin@linux.intel.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org, vinod.koul@intel.com,
	mengdong.lin@intel.com, broonie@kernel.org,
	rakesh.a.ughreja@intel.com, liam.r.girdwood@intel.com,
	hardik.t.shah@intel.com, subhransu.s.prusty@intel.com
Subject: Re: [PATCH 6/7] topology: Add support for parsing vendor tuples
Date: Wed, 30 Mar 2016 15:15:52 +0800	[thread overview]
Message-ID: <56FB7D28.5010504@linux.intel.com> (raw)
In-Reply-To: <s5hlh512wzi.wl-tiwai@suse.de>



On 03/29/2016 10:13 PM, Takashi Iwai wrote:
> On Thu, 24 Mar 2016 04:07:36 +0100,
> mengdong.lin@linux.intel.com wrote:
>>
>> +static int parse_tuple_set(snd_tplg_t *tplg, snd_config_t *cfg,
>> +	struct tplg_tuple_set **s)
> ....
>> +		switch (type) {
>> +		case SND_SOC_TPLG_TUPLE_TYPE_UUID:
>> +			memcpy(tuple->uuid, value, 16);
>
> This may become out-of-bound access.  Check the size of value string
> beforehand.

I'll fix this in v2.

>
>> +			tplg_dbg("\t\t%s = %s\n", tuple->token, tuple->uuid);
>> +			break;
>> +
>> +		case SND_SOC_TPLG_TUPLE_TYPE_STRING:
>> +			elem_copy_text(tuple->string, value,
>> +				SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
>> +			tplg_dbg("\t\t%s = %s\n", tuple->token, tuple->string);
>> +			break;
>> +
>> +		case SND_SOC_TPLG_TUPLE_TYPE_BOOL:
>> +			if (strcmp(value, "true") == 0)
>> +				tuple->value = 1;
>> +			tplg_dbg("\t\t%s = %d\n", tuple->token, tuple->value);
>> +			break;
>> +
>> +		case SND_SOC_TPLG_TUPLE_TYPE_BYTE:
>> +		case SND_SOC_TPLG_TUPLE_TYPE_SHORT:
>> +		case SND_SOC_TPLG_TUPLE_TYPE_WORD:
>> +			tuple->value = atoi(value);
>
> atoi() isn't good enough.  It can't handle a hex number, for example,
> and can't give an error.

Sorry. I missed this. I'll use strtol() to handle the data and check on 
the return value.

>> +/* Free handler of tuples */
>> +void tplg_free_tuples(void *obj)
>> +{
>> +	struct tplg_vendor_tuples *tuples = (struct tplg_vendor_tuples *)obj;
>> +	int i;
>> +
>> +	if (!tuples)
>> +		return;
>> +
>> +	for (i = 0; i < tuples->num_sets; i++)
>> +		free(tuples->set[i]);
>> +}
>
> tuples->set itself isn't freed?

This a memory leak. I'll fix this.

Thanks again for your review. I've sent out v2 with the fixes.

Regards
Mengdong

  reply	other threads:[~2016-03-30  7:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-24  3:05 [PATCH 0/7] topology: Add support for vendor tuples mengdong.lin
2016-03-24  3:06 ` [PATCH 1/7] topology: Use the generic pointer to free an element's object mengdong.lin
2016-03-24  3:06 ` [PATCH 2/7] topology: Define a free handler for the element mengdong.lin
2016-03-24  3:07 ` [PATCH 3/7] topology: Add doc for vendor tuples mengdong.lin
2016-03-24  3:07 ` [PATCH 4/7] topology: ABI - Define types " mengdong.lin
2016-03-24  3:07 ` [PATCH 5/7] topology: Add support for vendor tokens mengdong.lin
2016-03-24  3:07 ` [PATCH 6/7] topology: Add support for parsing vendor tuples mengdong.lin
2016-03-29 14:13   ` Takashi Iwai
2016-03-30  7:15     ` Mengdong Lin [this message]
2016-03-24  3:07 ` [PATCH 7/7] topology: Build data objects with tuples mengdong.lin
2016-03-24 11:20 ` [PATCH 0/7] topology: Add support for vendor tuples Mark Brown
2016-03-25  5:39   ` Mengdong Lin
2016-03-28  7:49     ` Mengdong Lin
2016-03-28  7:57       ` Takashi Iwai
2016-03-28  8:56         ` Mengdong Lin

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=56FB7D28.5010504@linux.intel.com \
    --to=mengdong.lin@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=hardik.t.shah@intel.com \
    --cc=liam.r.girdwood@intel.com \
    --cc=mengdong.lin@intel.com \
    --cc=rakesh.a.ughreja@intel.com \
    --cc=subhransu.s.prusty@intel.com \
    --cc=tiwai@suse.de \
    --cc=vinod.koul@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).