All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, Bin Yu <byu@xidian.edu.cn>,
	Cheng Wen <wencheng@xidian.edu.cn>,
	Johan Hovold <johan@kernel.org>
Subject: Re: [PATCH] ALSA: us122l: Fix NULL dereference at hwdep open and release
Date: Sat, 31 Oct 2026 16:41:21 +0100	[thread overview]
Message-ID: <87a4ntswri.wl-tiwai@suse.de> (raw)
In-Reply-To: <20261028074143.14440-1-25031212351@stu.xidian.edu.cn>

On Wed, 28 Oct 2026 08:41:43 +0100,
YuanZhe Liu wrote:
> 
> usb_stream_hwdep_open() and usb_stream_hwdep_release() pass the result of
> usb_ifnum_to_if() straight to usb_autopm_get_interface() and
> usb_autopm_put_interface(), without checking it for NULL.
> 
> usb_ifnum_to_if() returns NULL once the device is gone, since
> usb_disable_device() clears udev->actconfig on disconnect.  The hwdep file
> can outlive the disconnect: the card is released with
> snd_card_free_when_closed(), so a process that keeps the character device
> open reaches the driver's release callback after the USB configuration has
> been dropped, and interface_to_usbdev() then dereferences the NULL
> interface at offsetof(struct device, parent).  The open callback has the
> same problem when it races with the disconnect.
> 
> Check both lookups and fail the open with -ENODEV; in release, skip the
> runtime PM put when the interface is already gone and still run the rest
> of the per-file cleanup.  Move the us122l->first bookkeeping after the
> checks so that a failed open no longer leaves a stale file pointer behind.
> 
> Fixes: 030a07e44129 ("ALSA: Add USB US122L driver")
> Cc: stable@vger.kernel.org
> Co-developed-by: Bin Yu <byu@xidian.edu.cn>
> Signed-off-by: Bin Yu <byu@xidian.edu.cn>
> Co-developed-by: Cheng Wen <wencheng@xidian.edu.cn>
> Signed-off-by: Cheng Wen <wencheng@xidian.edu.cn>
> Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn>

Applied now.  Thanks.


Takashi

      parent reply	other threads:[~2026-10-31 15:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-28  7:41 [PATCH] ALSA: us122l: Fix NULL dereference at hwdep open and release YuanZhe Liu
2026-10-30 17:36 ` YuanZhe Liu
2026-10-31 15:41 ` 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=87a4ntswri.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=25031212351@stu.xidian.edu.cn \
    --cc=byu@xidian.edu.cn \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=stable@vger.kernel.org \
    --cc=tiwai@suse.com \
    --cc=wencheng@xidian.edu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.