Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp607579pxf; Wed, 31 Mar 2021 11:13:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy247++qQDMF9wPMQ5uhYQZr/Wh3XFcmVCIMHcKW+KPCjtVHJC3N36JnbVCgr0zy7T5gb/J X-Received: by 2002:a17:906:f0d0:: with SMTP id dk16mr5072656ejb.48.1617214403806; Wed, 31 Mar 2021 11:13:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617214403; cv=none; d=google.com; s=arc-20160816; b=RUXDTa6ZIppj1mdSgEj3icNWqDyl8UNDraNgoI7gDvteWJavuaMTquvs1vX6BY5oie 7MV9vmS20S6FepiKeZoLa8G9+6FFWkDu2EG+ScTPJZp5uOFBBABLUCjnkF8CKs0SGMDP 00ShiL4ZFXlNxtXv3sXeMwSgWF4dXGB70B8YsGPM029VFFECzmIZwYKPuZDTmtY9OuJu cSKgN7El8k/+v6IR2306ZaWhteoi1Iazs06ds5FACh6vHaNf66j5OsNSvOvbgwJdybOt 1Q5HN4LRtkKTYnkrBGUMCRlVlRkXnYheb8JL+G579kJXiGsyOGw67d6K2zsGEPGwYWeS hMTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:dkim-filter; bh=cVlBUFphs/dnp74K2p5kRDyfBDi3OUtOUvGdNmBLsP4=; b=EbTCmo5T6Zx7IQkV7rMN1An27WPqrLj7U26c2q9wG8elHU9q+W7Ye4dsDWWg26JM67 zr6ZLa8kgiCSecL3o3Wm1Mo5qK6oLf0dzoJSVauXUYmtAha8503s6bpAg8cS0adEZew2 dimIZKgbcv+IvLJVcZp6X2ffulJUt87sauq6kZvl+mHN8Xi6h9ZiC8bL1VwgL687rNC4 6eWd3P4SgKcW4yvLoSZgtQtLsyAj2+AXjnUI7vSAs9S/d26m3yY3LPB1NTjooa6KRogV VoKyzC3ziZiyiZs+m+8mdsq4iOl5aW9yQ6eD1eytXr6o+9TDZiKQMcKOvGYtaQ6Xc/YU otsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@perex.cz header.s=default header.b=sBeAQc3J; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=perex.cz Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ce13si2195704ejc.750.2021.03.31.11.13.01; Wed, 31 Mar 2021 11:13:23 -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=@perex.cz header.s=default header.b=sBeAQc3J; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=perex.cz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233900AbhCaSJp (ORCPT + 99 others); Wed, 31 Mar 2021 14:09:45 -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.