All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yuansheng Yang" <0xbeac@gmail.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH] ALSA: firewire-lib: clear protocol pointer in amdtp_stream_destroy()
Date: Sat, 05 Dec 2026 15:03:52 +0000	[thread overview]
Message-ID: <sashiko-outbox-251673@kernel.org> (raw)
In-Reply-To: <20261205145351.1712358-1-0xbeac@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] ALSA: firewire-lib: Fixes trailer cites wrong commit for
  double-free
--

commit 6e9bc1c90758880ff0ccb44d4ebbd1e733d08950
Author: Yuansheng Yang <0xbeac@gmail.com>

> ALSA: firewire-lib: clear protocol pointer in amdtp_stream_destroy()
>
> amdtp_stream_destroy() guards against destroying an uninitialized or
> already-destroyed stream by checking if s->protocol is NULL, then frees
> s->protocol via kfree() without resetting s->protocol to NULL.
>
> All ALSA FireWire drivers using snd_*_stream_init_duplex() (bebob, dice,
> digi00x, fireface, fireworks, motu, oxfw, and tascam) register
> card->private_free (which invokes snd_*_stream_destroy_duplex() ->
> amdtp_stream_destroy()) before calling snd_*_stream_init_duplex(). When
> snd_*_stream_init_duplex() fails after initializing at least one stream
> (for example, when snd_efw_command_set_tx_mode() fails after tx_stream
> and rx_stream have been initialized in snd_efw_stream_init_duplex(), or
> on any mid-duplex stream or domain initialization error),
> snd_*_stream_init_duplex() calls amdtp_stream_destroy() internally and
> leaves s->protocol dangling. The driver's probe error path then calls
> snd_card_free(), invoking amdtp_stream_destroy() a second time on the
> already-freed pointer:
>
>   BUG: KASAN: double-free in amdtp_stream_destroy
>   Call Trace:
>    kfree
>    amdtp_stream_destroy
>    snd_efw_stream_destroy_duplex
>    release_card_device
>    snd_card_free
>
> Clear s->protocol to NULL after kfree(s->protocol) in
> amdtp_stream_destroy() so a second call returns early at the NULL check,
> avoiding both the double kfree() and destroying s->mutex twice.
>
> Fixes: 44c376b9596c ("ALSA: firewire-lib: suppress kernel warnings when releasing uninitialized stream data")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yuansheng Yang <0xbeac@gmail.com>

[Severity: Low]
Should the Fixes tag cite df075feefbd3 ("ALSA: firewire-lib: complete
AM824 data block processing layer") instead?

Commit 44c376b9596c ("ALSA: firewire-lib: suppress kernel warnings when
releasing uninitialized stream data") only added the early NULL check on
s->protocol in amdtp_stream_destroy().

The s->protocol allocation and kfree(s->protocol) without clearing the
pointer were introduced earlier by that commit, when drivers such as
fireworks already registered card->private_free before duplex stream
init.  Pointing Fixes there keeps stable-backport tracking accurate:

  Fixes: df075feefbd3 ("ALSA: firewire-lib: complete AM824 data block processing layer")

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261205145351.1712358-1-0xbeac@gmail.com?part=1

      reply	other threads:[~2026-12-05 15:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05 14:53 [PATCH] ALSA: firewire-lib: clear protocol pointer in amdtp_stream_destroy() Yuansheng Yang
2026-12-05 15:03 ` sashiko-bot [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=sashiko-outbox-251673@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=0xbeac@gmail.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.