Skip to content

[26.04_linux-nvidia-bos] NVIDIA: SAUCE: ASoC: sdw_utils: clear stale device references in exit hooks - #561

Open
kbutala-nv wants to merge 2 commits into
NVIDIA:26.04_linux-nvidia-bosfrom
kbutala-nv:soc-sdw-reset-pointers-bos
Open

[26.04_linux-nvidia-bos] NVIDIA: SAUCE: ASoC: sdw_utils: clear stale device references in exit hooks#561
kbutala-nv wants to merge 2 commits into
NVIDIA:26.04_linux-nvidia-bosfrom
kbutala-nv:soc-sdw-reset-pointers-bos

Conversation

@kbutala-nv

Copy link
Copy Markdown

asoc_sdw_rt_amp_exit() drops the references held in ctx->amp_dev1 and ctx->amp_dev2, but leaves the pointers populated. If the card cleanup path runs the exit hook more than once, the same device references are dropped again, which can underflow the device refcount and leave stale pointers for later SoundWire bus walks.

In practice this can show up as refcount underflow warnings followed by an oops when later probe, driver bind, or suspend paths walk the SoundWire bus and touch the freed device.

This first part is fixed upstream via change 046173b

Clear the amplifier device pointers after put_device(), matching the idempotent pattern already used by the RT SDCA jack cleanup path. Do the same for the RT711 headset codec device pointer.

This second part is covered through second patch under this PR.

This makes the exit hooks safe to call after deferred or failed card probe paths and avoids stale device references being reused after cleanup.

This is tracked in internal bug 6290103

LP: https://bugs.launchpad.net/ubuntu/+source/linux-nvidia/+bug/2166188

Jack Yu and others added 2 commits September 2, 2026 21:43
In aggregation mode with two identical amplifiers,
a stress test that repeatedly triggers card unbind/rebind
can hit a NULL pointer dereference during the exit path.
ctx->amp_dev1 / ctx->amp_dev2 are single shared resources,
so the release must be safe against being called more than once.
Clear each pointer after put_device() so a second invocation
becomes a no-op, this could address NULL pointer dereference issue.

Signed-off-by: Jack Yu <jack.yu@realtek.com>
Link: https://patch.msgid.link/20260818023018.2564212-1-jack.yu@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
(cherry picked from commit 046173b)
Signed-off-by: Kaushal Rajeev Butala <kbutala@nvidia.com>
asoc_sdw_rt711_exit() drops the reference held in ctx->headset_codec_dev,
but leaves the pointer populated. If the card cleanup path reaches the exit
hook more than once after a failed or deferred probe, a later invocation
can reuse the stale pointer and call put_device() again.

Clear the pointer after put_device() so repeated cleanup becomes a no-op.
This avoids refcount underflow and possible oopses when later probe,
driver bind, or suspend paths walk the SoundWire bus after the device
reference was released.

This is similar to commit 046173b ("ASoC: sdw_utils: fix double
put_device() on aggregated amps").

Signed-off-by: David Cemin <dcemin@nvidia.com>
Signed-off-by: Kaushal Rajeev Butala <kbutala@nvidia.com>
@nirmoy nirmoy added the help wanted Extra attention is needed label Sep 2, 2026
@nirmoy

nirmoy commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

BaseOS Kernel Review

Tip

✅ Review passed

No issues found across the reviewed commits.

Findings: none

🔍 Review artifacts

📦 Kernel deb builds — 🟢 2/2 passed

Note

Build reports and debs are retained for 10 days after the PR closes.

Review metadata
  • Reviewed head: 1f771f576872
  • Overall status: passed
  • Architectures: 2/2 successful

This comment is maintained by BaseOS Reviewer and updated when the GitHub watcher publishes a newer review.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

PR Validation Report

Patchscan ✅ No Missing Fixes

All cherry-picked commits checked — no missing upstream fixes found.

PR Lint ✅ All checks passed

Details
Checking 2 commits...

Cherry-pick digest:
┌──────────────┬──────────────────────────────────────────────────────────────────┬────────────┬─────────┬───────────────────────────┐
│ Local        │ Referenced upstream / Patch subject                              │ Patch-ID   │ Subject │ SoB chain                 │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 1f771f576872 │ [SAUCE] asoc: sdw_utils: clear stale rt711 device reference      │ N/A        │ N/A     │ dcemin, kbutala           │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 1d40c94d9852 │ 046173b98de3 ASoC: sdw_utils: fix double put_device() on aggrega │ match      │ match   │ preserved + kbutala added │
└──────────────┴──────────────────────────────────────────────────────────────────┴────────────┴─────────┴───────────────────────────┘

Lint: all checks passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Extra attention is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants