From: Suraj Sonawane <surajsonawane0215@gmail.com>
To: lgirdwood@gmail.com, peter.ujfalusi@linux.intel.com,
yung-chuan.liao@linux.intel.com,
ranjani.sridharan@linux.intel.com, daniel.baluta@nxp.com,
kai.vehmanen@linux.intel.com, pierre-louis.bossart@linux.dev,
broonie@kernel.org, perex@perex.cz, tiwai@suse.com
Cc: sound-open-firmware@alsa-project.org,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
Suraj Sonawane <surajsonawane0215@gmail.com>
Subject: [PATCH] sound: fix uninit-value in sof_ipc4_pcm_dai_link_fixup_rate
Date: Wed, 30 Oct 2024 21:27:05 +0530 [thread overview]
Message-ID: <20241030155705.31327-1-surajsonawane0215@gmail.com> (raw)
Fix an issue detected by the Smatch tool:
sound/soc/sof/ipc4-pcm.c:615 sof_ipc4_pcm_dai_link_fixup_rate()
error: uninitialized symbol 'be_rate'.
sound/soc/sof/ipc4-pcm.c:636 sof_ipc4_pcm_dai_link_fixup_rate()
error: uninitialized symbol 'be_rate'.
These errors occurred because the variable 'be_rate' is declared but
may not be assigned a value before it is used. Specifically, if the
loop that assigns values to 'be_rate' does not execute (for example,
when 'num_input_formats' is zero), 'be_rate' remains uninitialized,
leading to potential undefined behavior.
To resolve this issue, initialize 'be_rate' to 0 at the point of
declaration. This ensures that 'be_rate' has a defined value before
it is used in subsequent calculations, preventing any warnings or
undefined behavior in cases where the loop does not run.
Signed-off-by: Suraj Sonawane <surajsonawane0215@gmail.com>
---
sound/soc/sof/ipc4-pcm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/sof/ipc4-pcm.c b/sound/soc/sof/ipc4-pcm.c
index 4df2be3d3..d08419859 100644
--- a/sound/soc/sof/ipc4-pcm.c
+++ b/sound/soc/sof/ipc4-pcm.c
@@ -600,7 +600,7 @@ static int sof_ipc4_pcm_dai_link_fixup_rate(struct snd_sof_dev *sdev,
unsigned int fe_rate = params_rate(params);
bool fe_be_rate_match = false;
bool single_be_rate = true;
- unsigned int be_rate;
+ unsigned int be_rate = 0;
int i;
/*
--
2.34.1
next reply other threads:[~2024-10-30 15:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-30 15:57 Suraj Sonawane [this message]
2024-10-30 17:10 ` [PATCH] sound: fix uninit-value in sof_ipc4_pcm_dai_link_fixup_rate Mark Brown
2024-10-31 6:02 ` Suraj Sonawane
2024-10-30 17:17 ` Mark Brown
2024-11-03 11:37 ` [PATCH v2] " Suraj Sonawane
2024-11-04 10:52 ` Péter Ujfalusi
2024-11-04 18:27 ` Mark Brown
2024-11-05 10:50 ` Suraj Sonawane
2024-11-05 19:07 ` Mark Brown
2024-11-06 8:34 ` Suraj Sonawane
2024-11-05 10:48 ` Suraj Sonawane
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=20241030155705.31327-1-surajsonawane0215@gmail.com \
--to=surajsonawane0215@gmail.com \
--cc=broonie@kernel.org \
--cc=daniel.baluta@nxp.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.dev \
--cc=ranjani.sridharan@linux.intel.com \
--cc=sound-open-firmware@alsa-project.org \
--cc=tiwai@suse.com \
--cc=yung-chuan.liao@linux.intel.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