Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1719831pxj; Fri, 21 May 2021 23:46:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEOatQYThtH8sVp+YTmJyYFDLzcTZfy9+UA5wbfffHdUnDyp5G54v2X4ZO96ycktnXAK96 X-Received: by 2002:a05:6e02:1b8f:: with SMTP id h15mr3538052ili.151.1621665982238; Fri, 21 May 2021 23:46:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621665982; cv=none; d=google.com; s=arc-20160816; b=OydWTkLDzgzNPMTX56E8QPq2hSjVKquFIm6KKbxluQjOtA93tYf+IXgTaeZaYdKG+G WcL+sb/pNLcNBAt8V8B2WINPKcohwRglVxnIpImJxrEBmIdbLPGZCEV05C1LiSE3OMSI ElHa1r1a28oiJ/bwSTEb58LufmoXY/fo6jNKmKNlLyNEFuQlt50S0dmu8cLg1qMa0XlJ e5kaKXubcso4WQrVhysSG3ZvO1QBp8z1C43uXtFH/XTlQ0GQ0Pi2ncWTOPBxXHdSCLpR qa2p2/LAjw8eMwTu3zyCOG5dgmzA51g9fwMV/lCXsqS50PfgQaCx8Y5oZbk9qVAgRGg7 up2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature:dkim-signature; bh=stNMbmkfr0H4CTD2K3KTiK4y5A/GN2rVn4bUsldoZ4c=; b=VjHyElPLzv8S389kkKniqKiW4e0jYmmV/QGh1Fc9IuyYf6jAW6N/GAin8E6FGVJB0A uwBS7QktZRjTdIcuBKqg3ExIWOCsTb0vS/gyrVxzzqCHUTWhnHSMtLp8XJRDscMTGxs4 hzJMFei67fiHiACaUtzNzby4oK260uvHM4vwF7lE1k1IpblaQPhoCC7EH9hUZLhporJ+ NSIRiB+Ct07Dc3Sjv6chA+n0HXq4G8vGGaGoLbHzbD++3ZcqERUxofgptsRs9mawlUyV sR9gQFIQsXj9lKpMhkixbYQruPo0YvEZ1RuTRbiiGhPw8UBb5VuuOGOFbiU+hQ8eO75B v03w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=QDYzRUel; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w18si8393248ilg.96.2021.05.21.23.46.09; Fri, 21 May 2021 23:46:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=QDYzRUel; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229989AbhEVGq7 (ORCPT + 99 others); Sat, 22 May 2021 02:46:59 -0400 Received: from mx2.suse.de ([195.135.220.15]:42126 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229689AbhEVGq6 (ORCPT ); Sat, 22 May 2021 02:46:58 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1621665933; 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=stNMbmkfr0H4CTD2K3KTiK4y5A/GN2rVn4bUsldoZ4c=; b=QDYzRUelPV6yLoPdmLyrdsVyYAOAd57fVYU3rKX9lyCzcDZ0HYWNCmaGklBiADgs2xzqo1 57H2nb8a8lu7ZPb0Otcwjdk9NMviR892T8IUJ25IfbXF9HtuzzBKtRGSFzOmDBghyh+MlI wvMdIiRrc5amtV+j+bj6sN8qmcfAEec= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1621665933; 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=stNMbmkfr0H4CTD2K3KTiK4y5A/GN2rVn4bUsldoZ4c=; b=eJQJNScSiAtI7hyaN5vliE9YnjF8RIC+wg9VLkVURHz0TPNfUXfrt8Eg3PNi4T++uqeA6c WMz2/+FtpcY4EIDA== Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id E85F4AAFD; Sat, 22 May 2021 06:45:32 +0000 (UTC) Date: Sat, 22 May 2021 08:45:32 +0200 Message-ID: From: Takashi Iwai To: Takashi Sakamoto Cc: Colin King , Clemens Ladisch , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH][next] ALSA: firewire-lib: Fix uninitialized variable err issue In-Reply-To: <20210521222146.GA10202@workstation> References: <20210520083424.6685-1-colin.king@canonical.com> <20210520130409.GA170303@workstation> <20210521222146.GA10202@workstation> 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: linux-kernel@vger.kernel.org On Sat, 22 May 2021 00:21:46 +0200, Takashi Sakamoto wrote: > > Hi, > > On Thu, May 20, 2021 at 10:04:09PM +0900, Takashi Sakamoto wrote: > > Hi, > > > > On Thu, May 20, 2021 at 02:26:24PM +0200, Takashi Iwai wrote: > > > On Thu, 20 May 2021 10:34:24 +0200, > > > Colin King wrote: > > > > > > > > From: Colin Ian King > > > > > > > > Currently in the case where the payload_length is less than the > > > > cip_header_size the error return variable err is not being set > > > > and function parse_ir_ctx_header can return an uninitialized > > > > error return value. Fix this by setting err to zero. > > > > > > > > Addresses-Coverity: ("Uninitialized scalar variable") > > > > Fixes: c09010eeb373 ("ALSA: firewire-lib: handle the case that empty isochronous packet payload for CIP") > > > > Signed-off-by: Colin Ian King > > > > > > Just a bikeshed, IMO, it'd be more proper to initialize err at the > > > beginning than setting 0 at every branch, e.g. > > > > > > --- a/sound/firewire/amdtp-stream.c > > > +++ b/sound/firewire/amdtp-stream.c > > > @@ -652,7 +652,7 @@ static int parse_ir_ctx_header(struct amdtp_stream *s, unsigned int cycle, > > > unsigned int payload_length; > > > const __be32 *cip_header; > > > unsigned int cip_header_size; > > > - int err; > > > + int err = 0; > > > > > > payload_length = be32_to_cpu(ctx_header[0]) >> ISO_DATA_LENGTH_SHIFT; > > > > > > @@ -683,7 +683,6 @@ static int parse_ir_ctx_header(struct amdtp_stream *s, unsigned int cycle, > > > } > > > } else { > > > cip_header = NULL; > > > - err = 0; > > > *data_blocks = payload_length / sizeof(__be32) / s->data_block_quadlets; > > > *syt = 0; > > > > Thanks for the patches. > > > > The error check is just done for the case to process CIP header, thus we > > can put the auto variable into the branch. > > > > ======== 8< -------- > > From 3fcca0062297e937c665f1c8e3a117e1187f4115 Mon Sep 17 00:00:00 2001 > > From: Takashi Sakamoto > > Date: Thu, 20 May 2021 21:59:50 +0900 > > Subject: [PATCH] ALSA: firewire-lib: Fix uninitialized variable err issue > > > > The check of error is just done for the case that CIP header is available. > > > > This commit moves auto variable into the branch to process CIP header. > > > > Addresses-Coverity: ("Uninitialized scalar variable") > > Fixes: c09010eeb373 ("ALSA: firewire-lib: handle the case that empty isochronous packet payload for CIP") > > Suggested-by: Colin Ian King > > Signed-off-by: Takashi Sakamoto > > --- > > sound/firewire/amdtp-stream.c | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c > > index 37c8de8a..11ae4e88 100644 > > --- a/sound/firewire/amdtp-stream.c > > +++ b/sound/firewire/amdtp-stream.c > > @@ -748,7 +748,6 @@ static int parse_ir_ctx_header(struct amdtp_stream *s, unsigned int cycle, > > unsigned int payload_length; > > const __be32 *cip_header; > > unsigned int cip_header_size; > > - int err; > > > > payload_length = be32_to_cpu(ctx_header[0]) >> ISO_DATA_LENGTH_SHIFT; > > > > @@ -766,6 +765,8 @@ static int parse_ir_ctx_header(struct amdtp_stream *s, unsigned int cycle, > > > > if (cip_header_size > 0) { > > if (payload_length >= cip_header_size) { > > + int err; > > + > > cip_header = ctx_header + IR_CTX_HEADER_DEFAULT_QUADLETS; > > err = check_cip_header(s, cip_header, payload_length - cip_header_size, > > data_blocks, data_block_counter, syt); > > @@ -779,7 +780,6 @@ static int parse_ir_ctx_header(struct amdtp_stream *s, unsigned int cycle, > > } > > } else { > > cip_header = NULL; > > - err = 0; > > *data_blocks = payload_length / sizeof(__be32) / s->data_block_quadlets; > > *syt = 0; > > > > @@ -790,7 +790,7 @@ static int parse_ir_ctx_header(struct amdtp_stream *s, unsigned int cycle, > > trace_amdtp_packet(s, cycle, cip_header, payload_length, *data_blocks, > > *data_block_counter, packet_index, index); > > > > - return err; > > + return 0; > > } > > > > // In CYCLE_TIMER register of IEEE 1394, 7 bits are used to represent second. On > > -- > > 2.27.0 > > ======== 8< -------- > > Thanks for applying the patch but the commit in your tree includes > duplicated From/Data/Subject lines and causes failure of git-am for the > patch simply generated by git-am. Is it possible for you to modify > history of your for-next branch with enough correction? My bad, now corrected. thanks, Takashi