mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stefan Binding <sbinding@opensource.cirrus.com>
To: Denis Arefev <arefev@swemel.ru>, David Rhodes <david.rhodes@cirrus.com>
Cc: 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, 7 Oct 2025 11:57:17 +0100	[thread overview]
Message-ID: <4ff0b878-9146-4f49-816e-bfd53a91122e@opensource.cirrus.com> (raw)
In-Reply-To: <20251007083959.7893-1-arefev@swemel.ru>

On 07/10/2025 09:39, 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>
> ---
>  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);

Would be good to print something to log an error, since otherwise this fails silently.

Thanks,

Stefan

>  	}
>  
>  	ret = component_master_add_with_match(dev, ops, match);

      parent reply	other threads:[~2025-10-07 11:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-07  8:39 Denis Arefev
2025-10-07  8:48 ` Takashi Iwai
2025-10-07 10:57 ` Stefan Binding [this message]

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=4ff0b878-9146-4f49-816e-bfd53a91122e@opensource.cirrus.com \
    --to=sbinding@opensource.cirrus.com \
    --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

all inboxes | Powered by JetHome®