public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Denis Arefev <arefev@swemel.ru>
Cc: David Rhodes <david.rhodes@cirrus.com>,
	Richard Fitzgerald <rf@opensource.cirrus.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	linux-sound@vger.kernel.org, patches@opensource.cirrus.com,
	linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] ALSA: hda: Fix missing pointer check in hda_component_manager_init function
Date: Tue, 07 Oct 2025 10:48:17 +0200	[thread overview]
Message-ID: <87tt0bdrn2.wl-tiwai@suse.de> (raw)
In-Reply-To: <20251007083959.7893-1-arefev@swemel.ru>

On Tue, 07 Oct 2025 10:39:57 +0200,
Denis Arefev wrote:
> 
> The __component_match_add function may assign the 'matchptr' pointer
> the value ERR_PTR(-ENOMEM), which will subsequently be dereferenced.
> 
> The call stack leading to the error looks like this: 
> 
> hda_component_manager_init
> |-> component_match_add
>     |-> component_match_add_release
>         |-> __component_match_add ( ... ,**matchptr, ... )
>             |-> *matchptr = ERR_PTR(-ENOMEM);       // assign 
> |-> component_master_add_with_match( ...  match)
>     |-> component_match_realloc(match, match->num); // dereference
> 
> Add IS_ERR() check to prevent the crash.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.          
> 
> Fixes: fd895a74dc1d ("ALSA: hda: realtek: Move hda_component implementation to module")
> Cc: stable@vger.kernel.org
> Signed-off-by: Denis Arefev <arefev@swemel.ru>

Thanks for the patch.

The Fixes tag isn't 100% correct, though; the given commit just moves
the code into another file, and the lack of the return value from
component_match_add() was present even before that commit, too.


Takashi


> ---
>  sound/hda/codecs/side-codecs/hda_component.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/sound/hda/codecs/side-codecs/hda_component.c b/sound/hda/codecs/side-codecs/hda_component.c
> index 71860e2d6377..84ddbab660e3 100644
> --- a/sound/hda/codecs/side-codecs/hda_component.c
> +++ b/sound/hda/codecs/side-codecs/hda_component.c
> @@ -181,6 +181,8 @@ int hda_component_manager_init(struct hda_codec *cdc,
>  		sm->match_str = match_str;
>  		sm->index = i;
>  		component_match_add(dev, &match, hda_comp_match_dev_name, sm);
> +		if (IS_ERR(match))
> +			return PTR_ERR(match);
>  	}
>  
>  	ret = component_master_add_with_match(dev, ops, match);
> -- 
> 2.43.0
> 

  reply	other threads:[~2025-10-07  8:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-07  8:39 [PATCH] ALSA: hda: Fix missing pointer check in hda_component_manager_init function Denis Arefev
2025-10-07  8:48 ` Takashi Iwai [this message]
2025-10-07 10:57 ` Stefan Binding

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=87tt0bdrn2.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=arefev@swemel.ru \
    --cc=david.rhodes@cirrus.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=patches@opensource.cirrus.com \
    --cc=perex@perex.cz \
    --cc=rf@opensource.cirrus.com \
    --cc=stable@vger.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