All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
To: Mark Brown <broonie@kernel.org>,
	Ethan Carter Edwards <ethan@ethancedwards.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-hardening@vger.kernel.org,
	Bard Liao <yung-chuan.liao@linux.intel.com>,
	shumingf@realtek.com
Subject: Re: [PATCH] ASoC: Intel: sof_sdw: initialize ret in asoc_sdw_rt_amp_spk_rtd_init()
Date: Tue, 11 Feb 2025 12:54:52 -0600	[thread overview]
Message-ID: <a97bf84a-21e8-41ce-8679-332630136ec5@linux.dev> (raw)
In-Reply-To: <ad5eb513-d3ef-42b8-b4a7-88a6ecf08804@sirena.org.uk>

On 2/11/25 07:13, Mark Brown wrote:
> On Mon, Feb 10, 2025 at 11:08:27PM -0500, Ethan Carter Edwards wrote:
>> There is a possibility for an uninitialized *ret* variable to be
>> returned in some code paths.
>>
>> Setting to 0 prevents a random value from being returned.
> 
> That'll shut up the warning but is the warning trying to tell us that
> there's a logic bug somewhere in the function and we're for example
> forgetting to look at a return value in some path in the function?

The problematic code is this:

for_each_rtd_codec_dais(rtd, i, codec_dai) {
	if (strstr(codec_dai->component->name_prefix, "-1"))
		ret = snd_soc_dapm_add_routes(&card->dapm, rt_amp_map, 2);
	else if (strstr(codec_dai->component->name_prefix, "-2"))
		ret = snd_soc_dapm_add_routes(&card->dapm, rt_amp_map + 2, 2);
}

return ret;

I am not sure if it's possible that either the for_each does nothing or that the two branches are skipped, but certainly initializing the 'ret' value makes sense to me.

Bard, Shuming, what do you think?




  reply	other threads:[~2025-02-11 18:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-11  4:08 [PATCH] ASoC: Intel: sof_sdw: initialize ret in asoc_sdw_rt_amp_spk_rtd_init() Ethan Carter Edwards
2025-02-11 13:13 ` Mark Brown
2025-02-11 18:54   ` Pierre-Louis Bossart [this message]
2025-04-07 18:02     ` Kees Cook

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=a97bf84a-21e8-41ce-8679-332630136ec5@linux.dev \
    --to=pierre-louis.bossart@linux.dev \
    --cc=broonie@kernel.org \
    --cc=ethan@ethancedwards.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=shumingf@realtek.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.