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=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 E9A6EC43460 for ; Wed, 31 Mar 2021 15:18:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C9C5561073 for ; Wed, 31 Mar 2021 15:18:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236344AbhCaPRi (ORCPT ); Wed, 31 Mar 2021 11:17:38 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:57266 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236320AbhCaPR0 (ORCPT ); Wed, 31 Mar 2021 11:17:26 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212]) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lRcay-0003ue-RA; Wed, 31 Mar 2021 15:17:24 +0000 To: Jaroslav Kysela From: Colin Ian King Subject: re: ALSA: control - add layer registration routines Cc: Takashi Iwai , Mark Brown , Takashi Sakamoto , alsa-devel@alsa-project.org, "linux-kernel@vger.kernel.org" Message-ID: <96e9bd5c-c8db-0db8-b393-fbf4a047dc80@canonical.com> Date: Wed, 31 Mar 2021 16:17:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 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 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. Colin