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=-7.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 4C45EC433ED for ; Wed, 31 Mar 2021 18:10:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E92360FF0 for ; Wed, 31 Mar 2021 18:10:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234537AbhCaSJq (ORCPT ); Wed, 31 Mar 2021 14:09:46 -0400 Received: from mail1.perex.cz ([77.48.224.245]:35946 "EHLO mail1.perex.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233735AbhCaSJa (ORCPT ); Wed, 31 Mar 2021 14:09:30 -0400 Received: from mail1.perex.cz (localhost [127.0.0.1]) by smtp1.perex.cz (Perex's E-mail Delivery System) with ESMTP id 50375A003F; Wed, 31 Mar 2021 20:09:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.perex.cz 50375A003F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=perex.cz; s=default; t=1617214165; bh=cVlBUFphs/dnp74K2p5kRDyfBDi3OUtOUvGdNmBLsP4=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=sBeAQc3JNSuqQS+Lcy4Gncbk+pJfATshMepPkXFUdX1HwkUhHIm1/haAjQb1Hfz1v 06blgNKsS56DwNFOFLb6Xs5AJa9bKGph6vBV7HxOpgXnDXj9M5tPNyrbEXSi3W7iVs qtfeT3BowNx5VOWrz/mJ6T/G6Dr0NJa8tC8mCyKk= Received: from p1gen2.localdomain (unknown [192.168.100.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: perex) by mail1.perex.cz (Perex's E-mail Delivery System) with ESMTPSA; Wed, 31 Mar 2021 20:09:19 +0200 (CEST) Subject: Re: ALSA: control - add layer registration routines To: Colin Ian King Cc: Takashi Iwai , Mark Brown , Takashi Sakamoto , alsa-devel@alsa-project.org, "linux-kernel@vger.kernel.org" References: <96e9bd5c-c8db-0db8-b393-fbf4a047dc80@canonical.com> From: Jaroslav Kysela Message-ID: <51ba335d-45ac-b50d-2ec6-333afd1daebf@perex.cz> Date: Wed, 31 Mar 2021 20:09:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <96e9bd5c-c8db-0db8-b393-fbf4a047dc80@canonical.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dne 31. 03. 21 v 17:17 Colin Ian King napsal(a): > Hi, > > Static analysis on linux-next with Coverity has detected a potential > issue in the following commit: > > commit 3f0638a0333bfdd0549985aa620f2ab69737af47 > Author: Jaroslav Kysela > Date: Wed Mar 17 18:29:41 2021 +0100 > > ALSA: control - add layer registration routines > > The static analysis is as follows: > > 2072 void snd_ctl_disconnect_layer(struct snd_ctl_layer_ops *lops) > 2073 { > 2074 struct snd_ctl_layer_ops *lops2, *prev_lops2; > 2075 > 2076 down_write(&snd_ctl_layer_rwsem); > > assignment: Assigning: prev_lops2 = NULL. > > 2077 for (lops2 = snd_ctl_layer, prev_lops2 = NULL; lops2; lops2 > = lops2->next) > 2078 if (lops2 == lops) { > > null: At condition prev_lops2, the value of prev_lops2 must be NULL. > dead_error_condition: The condition !prev_lops2 must be true. > > 2079 if (!prev_lops2) > 2080 snd_ctl_layer = lops->next; > 2081 else > > 'Constant' variable guards dead code (DEADCODE) dead_error_line: > Execution cannot reach this statement: prev_lops2->next = lops->next;. > Local variable prev_lops2 is assigned only once, to a constant > value, making it effectively constant throughout its scope. If this is > not the intent, examine the logic to see if there is a missing > assignment that would make prev_lops2 not remain constant. > > 2082 prev_lops2->next = lops->next; > 2083 break; > 2084 } > 2085 up_write(&snd_ctl_layer_rwsem); > 2086 } > > I couldn't quite figure out the original intent of the prev_lops use, so > I'd thought I'd report this issue as the code does look incorrect. Thank you. I submitted the fix here: https://lore.kernel.org/alsa-devel/20210331180702.663489-1-perex@perex.cz/ Jaroslav -- Jaroslav Kysela Linux Sound Maintainer; ALSA Project; Red Hat, Inc.