From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: "Lin, Mengdong" <mengdong.lin@intel.com>,
"mengdong.lin@linux.intel.com" <mengdong.lin@linux.intel.com>,
"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
"broonie@kernel.org" <broonie@kernel.org>
Cc: "tiwai@suse.de" <tiwai@suse.de>,
"Girdwood, Liam R" <liam.r.girdwood@intel.com>,
"Nc, Shreyas" <shreyas.nc@intel.com>
Subject: Re: [PATCH v2 2/2] topology: Fix the missing referenced elem ptr when merging private data
Date: Fri, 22 Jul 2016 12:28:11 +0900 [thread overview]
Message-ID: <579192CB.4030505@sakamocchi.jp> (raw)
In-Reply-To: <F46914AEC2663F4A9BB62374E5EEF8F84BA872AD@shsmsx102.ccr.corp.intel.com>
On Jul 22 2016 11:39, Lin, Mengdong wrote:
>> -----Original Message-----
>> From: Takashi Sakamoto [mailto:o-takashi@sakamocchi.jp]
>> Sent: Friday, July 22, 2016 10:16 AM
>> To: mengdong.lin@linux.intel.com; alsa-devel@alsa-project.org;
>> broonie@kernel.org
>> Cc: tiwai@suse.de; Lin, Mengdong; Girdwood, Liam R; Nc, Shreyas
>> Subject: Re: [PATCH v2 2/2] topology: Fix the missing referenced elem ptr
>> when merging private data
>>
>> On Jul 22 2016 10:47, mengdong.lin@linux.intel.com wrote:
>>> From: Mengdong Lin <mengdong.lin@linux.intel.com>
>>>
>>> tplg_copy_data() should set the valid referenced data element pointer
>>> on success. The caller will double check this pointer for all kinds of
>>> references, including controls and data.
>>>
>>> Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
>>>
>>> diff --git a/src/topology/data.c b/src/topology/data.c index
>>> 768fc27..e7793b2 100644
>>> --- a/src/topology/data.c
>>> +++ b/src/topology/data.c
>>> @@ -1078,6 +1078,8 @@ int tplg_copy_data(snd_tplg_t *tplg, struct
>> tplg_elem *elem,
>>> ref_elem->compound_elem = 1;
>>> memcpy(priv->data + old_priv_data_size,
>>> ref_elem->data->data, priv_data_size);
>>> +
>>> + ref->elem = ref_elem;
>>> return 0;
>>> }
>>
>> Is this really OK when the found topology element has no private data?
>> In this case, ref->elem has no assignment at return.
>
> No. This is my mistake. Thanks for finding this bug.
>
> ref->elem should still be assigned for this case. I will make it like this:
>
> /* overlook empty private data */
> if (!ref_elem->data || !ref_elem->data->size) {
> ref->elem = ref_elem;
> return 0;
> }
Let us split data merging code to an explicit function? Then:
if (ref_elem->data != NULL && ref_elem->data->size > 0) {
err = merge_private_data(elem, ref_elem);
if (err < 0)
return err;
}
ref->elem = ref_elem;
return 0;
(Here, I expect compiler optimization to merge the new function to
caller implicitly.)
Regards
Takashi Sakamoto
next prev parent reply other threads:[~2016-07-22 3:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-22 1:46 [PATCH v2 0/2] topology: Fix for handling widgets' references mengdong.lin
2016-07-22 1:46 ` [PATCH v2 1/2] topology: Fix inaccurate message on failure to find a widgets's reference mengdong.lin
2016-07-22 1:47 ` [PATCH v2 2/2] topology: Fix the missing referenced elem ptr when merging private data mengdong.lin
2016-07-22 2:16 ` Takashi Sakamoto
2016-07-22 2:39 ` Lin, Mengdong
2016-07-22 3:28 ` Takashi Sakamoto [this message]
2016-07-27 8:57 ` 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=579192CB.4030505@sakamocchi.jp \
--to=o-takashi@sakamocchi.jp \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=liam.r.girdwood@intel.com \
--cc=mengdong.lin@intel.com \
--cc=mengdong.lin@linux.intel.com \
--cc=shreyas.nc@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.