mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Pei Xiao <xiaopei01@kylinos.cn>
Cc: tiwai@suse.com, perex@perex.cz, quic_wcheng@quicinc.com,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ALSA: usb-audio: qcom: fix NULL pointer dereference in qmi_stop_session
Date: Tue, 24 Jun 2025 10:25:42 +0200	[thread overview]
Message-ID: <87qzz9lf5l.wl-tiwai@suse.de> (raw)
In-Reply-To: <9da1a13ffee0924e4813ef5b20625a89680ce88d.1750745062.git.xiaopei01@kylinos.cn>

On Tue, 24 Jun 2025 08:06:06 +0200,
Pei Xiao wrote:
> 
> The find_substream() call may return NULL, but the original error path
> dereferenced 'subs' unconditionally in dev_err(&subs->dev->dev, ...),
> causing a NULL pointer dereference when subs is NULL.
> 
> Fix by replacing dev_err with pr_err which doesn't require device context.
> This safely handles NULL subs while preserving the critical debugging
> information (pcm_card_num, pcm_dev_num, direction).
> 
> Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
> ---
>  sound/usb/qcom/qc_audio_offload.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/sound/usb/qcom/qc_audio_offload.c b/sound/usb/qcom/qc_audio_offload.c
> index 5bc27c82e0af..556fd9cb4fa6 100644
> --- a/sound/usb/qcom/qc_audio_offload.c
> +++ b/sound/usb/qcom/qc_audio_offload.c
> @@ -759,8 +759,7 @@ static void qmi_stop_session(void)
>  			subs = find_substream(pcm_card_num, info->pcm_dev_num,
>  					      info->direction);
>  			if (!subs || !chip || atomic_read(&chip->shutdown)) {
> -				dev_err(&subs->dev->dev,
> -					"no sub for c#%u dev#%u dir%u\n",
> +				pr_err("no sub for c#%u dev#%u dir%u\n",
>  					info->pcm_card_num,
>  					info->pcm_dev_num,
>  					info->direction);

if we replace with pr_err(), it should show a bit more relevant
information; otherwise user can't know who spews this error for what
reason.

Alternatively, we may replace the device pointer with another existing
device, e.g. uadev[idx].udev->dev, too.


thanks,

Takashi

      reply	other threads:[~2025-06-24  8:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-24  6:06 Pei Xiao
2025-06-24  8:25 ` Takashi Iwai [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=87qzz9lf5l.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=quic_wcheng@quicinc.com \
    --cc=tiwai@suse.com \
    --cc=xiaopei01@kylinos.cn \
    /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®