From: Suraj Sonawane <surajsonawane0215@gmail.com>
To: Mark Brown <broonie@kernel.org>
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
Subject: Re: [PATCH] sound: fix uninit-value in i2s_dma_isr
Date: Fri, 1 Nov 2024 14:32:43 +0530 [thread overview]
Message-ID: <e8fe072a-e1b9-41b0-9382-6562139e31d3@gmail.com> (raw)
In-Reply-To: <d97a58c7-347b-48f9-aa69-d4ff5a4038e3@sirena.org.uk>
On 31/10/24 21:47, Mark Brown wrote:
> On Thu, Oct 31, 2024 at 12:17:56PM +0530, Suraj Sonawane wrote:
>> On 30/10/24 22:44, Mark Brown wrote:
>
>>> This will shut the warning up, but why are these values valid? Are we
>>> handling the cases where the loops do not execute properly?
>
>> Thank you for the feedback and your time.
>
>> The uninitialized warning for val_1 and val_2 arises because, in some cases,
>> the offlevel value is zero, and as a result, the loop does not execute,
>> leaving these variables potentially undefined. The subsequent code
>> calculates prtd->dma_addr_next using val_1 + val_2, so it's necessary to
>> have val_1 and val_2 initialized to a known value, even when the loop does
>> not run.
>
>> Initializing them to zero ensures prtd->dma_addr_next has a defined value
>> without triggering undefined behavior. However, if a zero initialization
>> could cause unintended behavior in dma_addr_next, I could alternatively
>> handle this case by setting dma_addr_next conditionally when offlevel is
>> non-zero.
>
> This is describing again what the patch does, which basically just boils
> down to shutting up the warning.
>
>> Let me know if there’s a preferred approach, or if you'd suggest a different
>> initial value for these variables based on the expected use.
>
> We need to understand what the change is doing - what do the values
> mean, is the real issue that we're missing some error handling for the
> case that lets us fall through without initialisation?
Thank you for clarifying.
I reviewed the context around val_1 and val_2 in dma_addr_next. These
values are expected to come from the registers when offlevel is
non-zero, representing the next DMA address and length information. If
offlevel is zero, it means there’s no offset data to process, and
dma_addr_next might not need updating in that case.
A more precise solution would be to conditionally update
prtd->dma_addr_next only when offlevel is non-zero, as this would
reflect the intended logic without relying on an arbitrary initialization.
Would it be better to revise the patch to conditionally update
prtd->dma_addr_next only when offlevel is non-zero?
Let me know if this approach aligns better with the expected behavior.
Thank you again for your time.
Thanks,
Suraj
next prev parent reply other threads:[~2024-11-01 9:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-30 17:08 [PATCH] sound: fix uninit-value in i2s_dma_isr Suraj Sonawane
2024-10-30 17:14 ` Mark Brown
2024-10-31 6:47 ` Suraj Sonawane
2024-10-31 16:17 ` Mark Brown
2024-11-01 9:02 ` Suraj Sonawane [this message]
2024-11-01 13:15 ` Mark Brown
2024-11-02 12:40 ` Suraj Sonawane
2024-11-02 12:36 ` [PATCH v2] " Suraj Sonawane
2024-11-04 12:41 ` Mark Brown
2024-11-05 11:03 ` Suraj Sonawane
2024-11-05 16:38 ` Mark Brown
2024-11-06 8:24 ` 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=e8fe072a-e1b9-41b0-9382-6562139e31d3@gmail.com \
--to=surajsonawane0215@gmail.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@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