From: Colin Ian King <colin.king@canonical.com>
To: Jaroslav Kysela <perex@perex.cz>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
alsa-devel@alsa-project.org, Mark Brown <broonie@kernel.org>,
Takashi Iwai <tiwai@suse.com>
Subject: re: ALSA: control - add layer registration routines
Date: Wed, 31 Mar 2021 16:17:24 +0100 [thread overview]
Message-ID: <96e9bd5c-c8db-0db8-b393-fbf4a047dc80@canonical.com> (raw)
Hi,
Static analysis on linux-next with Coverity has detected a potential
issue in the following commit:
commit 3f0638a0333bfdd0549985aa620f2ab69737af47
Author: Jaroslav Kysela <perex@perex.cz>
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
next reply other threads:[~2021-03-31 15:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-31 15:17 Colin Ian King [this message]
2021-03-31 18:09 ` ALSA: control - add layer registration routines Jaroslav Kysela
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=96e9bd5c-c8db-0db8-b393-fbf4a047dc80@canonical.com \
--to=colin.king@canonical.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).