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 X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6169C433B4 for ; Thu, 20 May 2021 12:28:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 85F8F61355 for ; Thu, 20 May 2021 12:28:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231651AbhETM3h (ORCPT ); Thu, 20 May 2021 08:29:37 -0400 Received: from mx2.suse.de ([195.135.220.15]:37012 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239749AbhETM1x (ORCPT ); Thu, 20 May 2021 08:27:53 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 1F6ECAC4B; Thu, 20 May 2021 12:26:24 +0000 (UTC) Date: Thu, 20 May 2021 14:26:24 +0200 Message-ID: From: Takashi Iwai To: Colin King Cc: Clemens Ladisch , Takashi Sakamoto , 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: <20210520083424.6685-1-colin.king@canonical.com> References: <20210520083424.6685-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: linux-kernel@vger.kernel.org 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, Takashi