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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B0CF5C433F5 for ; Fri, 4 Mar 2022 11:29:22 +0000 (UTC) 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 1927418CA; Fri, 4 Mar 2022 12:28:30 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1927418CA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1646393360; bh=XdZzCg3lQzD436i7PrhtrwbuzP03WT12BFIP80rNj0Y=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ZoRFXbZidYRB7+hOeqaiZHa/1AmUCYyeBhoDG8qYUVjhucgXbN0LmgVyNE6h2VbkI HGhiN/4iY3lbvjlLE8wc7zzJdYpTrm3mlD0ifzJH8EiAymOT5I1g9z+DHBIYeVMsmw 0OrJlJBizCNY0nx94Fhh+ypIp4KvQUQqInhqSUVs= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 9B4A0F80139; Fri, 4 Mar 2022 12:28:29 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B607BF801EC; Fri, 4 Mar 2022 12:28:26 +0100 (CET) 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 0C74CF800FA for ; Fri, 4 Mar 2022 12:28:15 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0C74CF800FA Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="lxaWNUJf"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="2SDyWCik" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 5212E1F387; Fri, 4 Mar 2022 11:28:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1646393295; 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=r4bUUWOE/ergbXemmAlzi1XBS8wFFYd+ABVY4rAugmE=; b=lxaWNUJfbww3av64rKSCglcuO7DX8dZJDJlL6hwo6mowiCXYkjc8lR4ikV9kmk3C3Wsry0 mFYExKXOh+bLgB4qn6VTTsyrNjh8qGraxqEj2PudKL/Ekp8FHonFKbZ1xKHqG5GnkhrNxN uZdaOLBZLCL5rRqt7k2wcy0A6JPob2s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1646393295; 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=r4bUUWOE/ergbXemmAlzi1XBS8wFFYd+ABVY4rAugmE=; b=2SDyWCik8JtuKf+lpbQGsymitRiJo0GuD7w7JblxXi+BeiiR5XqANjf9hLuTWY14wAuKRE EKNLDfwqKiQzypDg== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 3EE61A3B8C; Fri, 4 Mar 2022 11:28:15 +0000 (UTC) Date: Fri, 04 Mar 2022 12:28:15 +0100 Message-ID: From: Takashi Iwai To: Takashi Sakamoto Subject: Re: [PATCH] ALSA: firewire-lib: fix uninitialized flag for AV/C deferred transaction In-Reply-To: <20220304110124.68988-1-o-takashi@sakamocchi.jp> References: <20220304110124.68988-1-o-takashi@sakamocchi.jp> 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, clemens@ladisch.de 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, 04 Mar 2022 12:01:24 +0100, Takashi Sakamoto wrote: > > AV/C deferred transaction was supported at a commit 00a7bb81c20f ("ALSA: > firewire-lib: Add support for deferred transaction") while 'deferrable' > flag can be uninitialized for non-control/notify AV/C transactions. > UBSAN reports it: > > kernel: ================================================================================ > kernel: UBSAN: invalid-load in /build/linux-aa0B4d/linux-5.15.0/sound/firewire/fcp.c:363:9 > kernel: load of value 158 is not a valid value for type '_Bool' > kernel: CPU: 3 PID: 182227 Comm: irq/35-firewire Tainted: P OE 5.15.0-18-generic #18-Ubuntu > kernel: Hardware name: Gigabyte Technology Co., Ltd. AX370-Gaming 5/AX370-Gaming 5, BIOS F42b 08/01/2019 > kernel: Call Trace: > kernel: > kernel: show_stack+0x52/0x58 > kernel: dump_stack_lvl+0x4a/0x5f > kernel: dump_stack+0x10/0x12 > kernel: ubsan_epilogue+0x9/0x45 > kernel: __ubsan_handle_load_invalid_value.cold+0x44/0x49 > kernel: fcp_response.part.0.cold+0x1a/0x2b [snd_firewire_lib] > kernel: fcp_response+0x28/0x30 [snd_firewire_lib] > kernel: fw_core_handle_request+0x230/0x3d0 [firewire_core] > kernel: handle_ar_packet+0x1d9/0x200 [firewire_ohci] > kernel: ? handle_ar_packet+0x1d9/0x200 [firewire_ohci] > kernel: ? transmit_complete_callback+0x9f/0x120 [firewire_core] > kernel: ar_context_tasklet+0xa8/0x2e0 [firewire_ohci] > kernel: tasklet_action_common.constprop.0+0xea/0xf0 > kernel: tasklet_action+0x22/0x30 > kernel: __do_softirq+0xd9/0x2e3 > kernel: ? irq_finalize_oneshot.part.0+0xf0/0xf0 > kernel: do_softirq+0x75/0xa0 > kernel: > kernel: > kernel: __local_bh_enable_ip+0x50/0x60 > kernel: irq_forced_thread_fn+0x7e/0x90 > kernel: irq_thread+0xba/0x190 > kernel: ? irq_thread_fn+0x60/0x60 > kernel: kthread+0x11e/0x140 > kernel: ? irq_thread_check_affinity+0xf0/0xf0 > kernel: ? set_kthread_struct+0x50/0x50 > kernel: ret_from_fork+0x22/0x30 > kernel: > kernel: ================================================================================ > > This commit fixes the bug. The bug has no disadvantage for the non- > control/notify AV/C transactions since the flag has an effect for AV/C > response with INTERIM (0x0f) status which is not used for the transactions > in AV/C general specification. > > Fixes: 00a7bb81c20f ("ALSA: firewire-lib: Add support for deferred transaction") > Signed-off-by: Takashi Sakamoto > --- > sound/firewire/fcp.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/sound/firewire/fcp.c b/sound/firewire/fcp.c > index bbfbebf4affb..564607e083ca 100644 > --- a/sound/firewire/fcp.c > +++ b/sound/firewire/fcp.c > @@ -240,9 +240,7 @@ int fcp_avc_transaction(struct fw_unit *unit, > t.response_match_bytes = response_match_bytes; > t.state = STATE_PENDING; > init_waitqueue_head(&t.wait); > - > - if (*(const u8 *)command == 0x00 || *(const u8 *)command == 0x03) > - t.deferrable = true; > + t.deferrable = !!(*(const u8 *)command == 0x00 || *(const u8 *)command == 0x03); The "!!" is superfluous as the comparison results are already boolean. thanks, Takashi