From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A34A6C433EF for ; Fri, 1 Oct 2021 10:49:36 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 42926604DC for ; Fri, 1 Oct 2021 10:49:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 42926604DC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0668C16CA; Fri, 1 Oct 2021 12:48:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0668C16CA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1633085373; bh=SvZRBcwFCAkjLn28ZXFMAlx/GgeMVGSxOtYy0lJYUeo=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=RJ49e+pwDSMawz80HN3bLZPId0aXW3857HJR1JQjokfx7GJscl0zRQo/TCeuInmtq ijcxf1emhrMvbsp0JjQ1ugyw9adRLtX0Q3ipRHDHl1L7310Uasd9OiyfOj7lVwBCqD lMpJqxTlIJEjpNuqwUUpWoYdsm118cYnnQhsdE1g= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 5CCA9F80227; Fri, 1 Oct 2021 12:48:42 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 48516F80245; Fri, 1 Oct 2021 12:48:40 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id CC8AEF801F7 for ; Fri, 1 Oct 2021 12:48:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CC8AEF801F7 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="IskfcKfi"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="EIGN09vb" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 994711FD61; Fri, 1 Oct 2021 10:48:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1633085309; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=NysnsI/e5faCEp+kLmLJ5w8n+/uCw/Z1o1IAQZbc4OY=; b=IskfcKfihcAh9i9hI/07/freT+imtqyJ7RH7gfED0K/OnJ+XLayt59YNvovU06gwdyCzfO bttW7vjH/qL7hNDzFx3Pj/V5fLPlugJcL8E1Vq2+6BSbYw+oyh08RgYyqHW5bFwgFBx4Vt tH6tJIFMz59sg2BWuC92moylC88+EuM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1633085309; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=NysnsI/e5faCEp+kLmLJ5w8n+/uCw/Z1o1IAQZbc4OY=; b=EIGN09vbyN/Kvckj2OqhikWMi8PsU0BnfUEwZNWYbtn61aNmgtkMonPe/1EkyxWlFCxmPg yJklWgEULlL4XpDg== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 70A2BA3B83; Fri, 1 Oct 2021 10:48:29 +0000 (UTC) Date: Fri, 01 Oct 2021 12:48:29 +0200 Message-ID: From: Takashi Iwai To: Colin King Subject: Re: [PATCH][next] ALSA: usb-audio: Fix sum of uninitialized variable sample_accum In-Reply-To: <20211001104417.14291-1-colin.king@canonical.com> References: <20211001104417.14291-1-colin.king@canonical.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Cc: alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, Takashi Iwai , Alexander Tsoy X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Fri, 01 Oct 2021 12:44:17 +0200, Colin King wrote: > > From: Colin Ian King > > 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 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. 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 > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADB6CC433EF for ; Fri, 1 Oct 2021 10:48:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7EA3261A56 for ; Fri, 1 Oct 2021 10:48:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353661AbhJAKuT (ORCPT ); Fri, 1 Oct 2021 06:50:19 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:41328 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231237AbhJAKuP (ORCPT ); Fri, 1 Oct 2021 06:50:15 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 994711FD61; Fri, 1 Oct 2021 10:48:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1633085309; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=NysnsI/e5faCEp+kLmLJ5w8n+/uCw/Z1o1IAQZbc4OY=; b=IskfcKfihcAh9i9hI/07/freT+imtqyJ7RH7gfED0K/OnJ+XLayt59YNvovU06gwdyCzfO bttW7vjH/qL7hNDzFx3Pj/V5fLPlugJcL8E1Vq2+6BSbYw+oyh08RgYyqHW5bFwgFBx4Vt tH6tJIFMz59sg2BWuC92moylC88+EuM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1633085309; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=NysnsI/e5faCEp+kLmLJ5w8n+/uCw/Z1o1IAQZbc4OY=; b=EIGN09vbyN/Kvckj2OqhikWMi8PsU0BnfUEwZNWYbtn61aNmgtkMonPe/1EkyxWlFCxmPg yJklWgEULlL4XpDg== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 70A2BA3B83; Fri, 1 Oct 2021 10:48:29 +0000 (UTC) Date: Fri, 01 Oct 2021 12:48:29 +0200 Message-ID: From: Takashi Iwai To: Colin King Cc: Jaroslav Kysela , Takashi Iwai , Alexander Tsoy , 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 In-Reply-To: <20211001104417.14291-1-colin.king@canonical.com> References: <20211001104417.14291-1-colin.king@canonical.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: kernel-janitors@vger.kernel.org On Fri, 01 Oct 2021 12:44:17 +0200, Colin King wrote: > > From: Colin Ian King > > 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 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. 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 >