From: Takashi Iwai <tiwai@suse.de>
To: hariconscious@gmail.com
Cc: perex@perex.cz, tiwai@suse.com, khalid@kernel.org,
shuah@kernel.org, david.hunter.linux@gmail.com,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sound/core/seq: Initialize structure pointer to NULL to prevent undefined behavior
Date: Fri, 03 Oct 2025 09:21:36 +0200 [thread overview]
Message-ID: <87o6qoh2m7.wl-tiwai@suse.de> (raw)
In-Reply-To: <20251002174301.15512-1-hariconscious@gmail.com>
On Thu, 02 Oct 2025 19:43:00 +0200,
hariconscious@gmail.com wrote:
>
> From: HariKrishna Sagala <hariconscious@gmail.com>
>
> This change ensures the structure pointer is explicitly initialized to
> NULL,preventing potential access to uninitialized memory. It improves
> code safety and avoids undefined behavior during pointer dereferencing.
>
> Signed-off-by: HariKrishna Sagala <hariconscious@gmail.com>
> ---
>
> Note:
> Turned on the settings needed for sequencer MIDI and built a kernel
> image with those settings. The system booted up fine with no errors.
> However, couldn’t get the sequencer emulation to start.
Something really wrong in your test, I'm afraid.
See your patch below more closely:
>
> sound/core/seq/seq_midi_emul.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/sound/core/seq/seq_midi_emul.c b/sound/core/seq/seq_midi_emul.c
> index 81d2ef5e5811..f24c5a475c41 100644
> --- a/sound/core/seq/seq_midi_emul.c
> +++ b/sound/core/seq/seq_midi_emul.c
> @@ -647,7 +647,7 @@ static void snd_midi_channel_init(struct snd_midi_channel *p, int n)
> */
> static struct snd_midi_channel *snd_midi_channel_init_set(int n)
> {
> - struct snd_midi_channel *chan;
> + struct snd_midi_channel *chan = NULL;
> int i;
>
> chan = kmalloc_array(n, sizeof(struct snd_midi_channel), GFP_KERNEL);
The variable chan is initialized at the very beginning.
NULL initialization is utterly nonsense.
> @@ -686,7 +686,7 @@ reset_all_channels(struct snd_midi_channel_set *chset)
> */
> struct snd_midi_channel_set *snd_midi_channel_alloc_set(int n)
> {
> - struct snd_midi_channel_set *chset;
> + struct snd_midi_channel_set *chset = NULL;
>
> chset = kmalloc(sizeof(*chset), GFP_KERNEL);
Here, too.
So all changes make really no sense.
thanks,
Takashi
next prev parent reply other threads:[~2025-10-03 7:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-02 17:43 [PATCH] sound/core/seq: Initialize structure pointer to NULL to prevent undefined behavior hariconscious
2025-10-03 7:21 ` Takashi Iwai [this message]
2025-10-06 3:55 ` David Hunter
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=87o6qoh2m7.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=david.hunter.linux@gmail.com \
--cc=hariconscious@gmail.com \
--cc=khalid@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=shuah@kernel.org \
--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