From: Colin Ian King <colin.king@canonical.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Alexander Tsoy <alexander@tsoy.me>,
alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] ALSA: usb-audio: Fix sum of uninitialized variable sample_accum
Date: Fri, 1 Oct 2021 12:07:03 +0100 [thread overview]
Message-ID: <0bce4268-cac5-4dee-451d-cfafb5efdb8b@canonical.com> (raw)
In-Reply-To: <s5htui1hvgi.wl-tiwai@suse.de>
On 01/10/2021 11:48, Takashi Iwai wrote:
> On Fri, 01 Oct 2021 12:44:17 +0200,
> Colin King wrote:
>>
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Variable sample_accum is not being intialized and then has
>> ep->sample_rem added to it, leading to a bogus value. One solution
>> is to initialize it to zero at declaration time, but it is probably
>> best to just assign it to ep->sample_rem on first use.
>>
>> Addresses-Coveriry: ("Uninitialized scalar variable")
>> Fixes: f0bd62b64016 ("ALSA: usb-audio: Improve frames size computation")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>
> Thanks for the patch, but it's no right fix. The Fixes tag points to
> a wrong commit, it was d215f63d49da9a8803af3e81acd6cad743686573
> ALSA: usb-audio: Check available frames for the next packet size
>
> And sample_accum has to be initialized from ep->sample_accum instead.
> I'll post the proper fix.
Thanks Takshi.
Colin
>
>
> Takashi
>
>
>> ---
>> sound/usb/endpoint.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
>> index 42c0d2db8ba8..c6a33732db3f 100644
>> --- a/sound/usb/endpoint.c
>> +++ b/sound/usb/endpoint.c
>> @@ -182,7 +182,7 @@ static int next_packet_size(struct snd_usb_endpoint *ep, unsigned int avail)
>> if (ep->fill_max)
>> return ep->maxframesize;
>>
>> - sample_accum += ep->sample_rem;
>> + sample_accum = ep->sample_rem;
>> if (sample_accum >= ep->pps) {
>> sample_accum -= ep->pps;
>> ret = ep->packsize[1];
>> --
>> 2.32.0
>>
prev parent reply other threads:[~2021-10-01 11:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-01 10:44 [PATCH][next] ALSA: usb-audio: Fix sum of uninitialized variable sample_accum Colin King
2021-10-01 10:48 ` Takashi Iwai
2021-10-01 11:07 ` Colin Ian King [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=0bce4268-cac5-4dee-451d-cfafb5efdb8b@canonical.com \
--to=colin.king@canonical.com \
--cc=alexander@tsoy.me \
--cc=alsa-devel@alsa-project.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.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