From: sashiko-bot@kernel.org
To: "Charles Keepax" <ckeepax@opensource.cirrus.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH v4 4/4] soundwire: intel_auxdevice: Don't disable IRQs before removing children
Date: Tue, 24 Nov 2026 16:27:00 +0000 [thread overview]
Message-ID: <sashiko-outbox-231558@kernel.org> (raw)
In-Reply-To: <20261124161001.702882-5-ckeepax@opensource.cirrus.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] soundwire: free_irq() called before disabling IRQs in
intel_link_remove()
- [Medium] soundwire: cdns->work races with devres release in
sdw_bus_slaves_delete()
- [Medium] soundwire: missing free_irq() on error path in
intel_link_probe()
--
commit 7c3721ba123431be83148cab636e34ed615878ea
Author: Charles Keepax <ckeepax@opensource.cirrus.com>
soundwire: intel_auxdevice: Don't disable IRQs before removing children
This commit defers freeing the link IRQ and disabling Cadence interrupts
in intel_link_remove() until after sdw_bus_slaves_delete() has removed the
child slave devices.
> diff --git a/drivers/soundwire/intel_auxdevice.c b/drivers/soundwire/intel_auxdevice.c
> index d84fbe716febc..450c3927f0910 100644
> --- a/drivers/soundwire/intel_auxdevice.c
> +++ b/drivers/soundwire/intel_auxdevice.c
> @@ -511,8 +511,6 @@ static void intel_link_remove(struct auxiliary_device *auxdev)
> struct sdw_intel *sdw = cdns_to_intel(cdns);
> struct sdw_bus *bus = &cdns->bus;
>
> - free_irq(sdw->link_res->irq, cdns);
> -
> /*
> * Since pm_runtime is already disabled, we don't decrease
> * the refcount when the clock_stop_quirk is
> @@ -521,8 +519,15 @@ static void intel_link_remove(struct auxiliary_device *auxdev)
> if (!bus->prop.hw_disabled) {
> sdw_intel_debugfs_exit(sdw);
> cancel_delayed_work_sync(&cdns->attach_dwork);
> - sdw_cdns_enable_interrupt(cdns, false);
> }
> +
> + sdw_bus_slaves_delete(bus);
[Severity: Medium]
Can cdns_update_slave_status_work() race with sdw_bus_slaves_delete() and
access resources already released by device_del()?
Because commit "soundwire: bus: Don't unassign dev_num before
unregistering device" leaves slave->dev_num set in bus->assigned and the
slave on bus->slaves until sdw_bus_master_delete() calls
sdw_bus_slaves_put(), a concurrent status update work item still looks up
the slave after device_del() has released its devres allocations:
CPU0 CPU1 (kworker)
intel_link_remove()
sdw_bus_slaves_delete(bus)
sdw_delete_slave()
device_del(&slave->dev)
...
devres_release_all()
sdw_irq_dispose_mapping()
irq_dispose_mapping(slave->irq)
/* frees prop->dp0_prop */
cdns_update_slave_status_work()
sdw_handle_slave_status()
sdw_handle_slave_alerts()
handle_nested_irq(slave->irq)
<-- NULL deref / use-after-free
In sdw_handle_slave_alerts(), handle_nested_irq(slave->irq) runs outside
slave->sdw_dev_lock without checking slave->probed after slave->irq has
been disposed. Similarly, if the slave transitions to SDW_SLAVE_ATTACHED,
sdw_initialize_slave() dereferences the devm-freed slave->prop.dp0_prop.
> +
> + free_irq(sdw->link_res->irq, cdns);
> +
> + if (!bus->prop.hw_disabled)
> + sdw_cdns_enable_interrupt(cdns, false);
[Severity: Medium]
Should sdw_cdns_enable_interrupt(cdns, false) be called before free_irq()?
sdw_cdns_enable_interrupt(cdns, false) sets cdns->interrupt_enabled to
false, calls cancel_work_sync(&cdns->work), and then clears
CDNS_MCP_INTMASK. When free_irq() runs first, any in-flight
cdns_update_slave_status_work() waiting in _cdns_xfer_msg() on
cdns->tx_complete has no sdw_cdns_irq() handler registered to service
CDNS_MCP_INT_RX_WL, so each bus transfer blocks for CDNS_TX_TIMEOUT
(500 ms). In addition, while CDNS_MCP_INTMASK remains enabled after
free_irq(), any asserted Cadence interrupt has no handler on
sdw->link_res->irq to clear CDNS_MCP_INTSTAT.
[Severity: Medium]
In intel_link_probe(), added by commit "ASoC: SOF: Intel: Add IRQ chip to
distribute the SoundWire IRQ", does a failure in sdw_bus_master_add() leak
sdw->link_res->irq and leave cdns registered as the IRQ dev_id after devres
frees sdw?
drivers/soundwire/intel_auxdevice.c:intel_link_probe() {
...
ret = request_threaded_irq(sdw->link_res->irq, NULL, sdw_cdns_irq,
IRQF_SHARED | IRQF_ONESHOT, dev_name(dev),
cdns);
if (ret) {
dev_err(dev, "failed to request IRQ: %d\n", ret);
return ret;
}
ret = sdw_bus_master_add(bus, dev, dev->fwnode);
if (ret) {
dev_err(dev, "sdw_bus_master_add fail: %d\n", ret);
return ret;
}
...
}
Because sdw is allocated with devm_kzalloc_obj(dev, *sdw) while
request_threaded_irq() is non-managed, returning without calling
free_irq(sdw->link_res->irq, cdns) leaves sdw_cdns_irq() active on the
shared interrupt line with a freed dev_id pointer.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124161001.702882-1-ckeepax@opensource.cirrus.com?part=4
prev parent reply other threads:[~2026-11-24 16:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 16:09 [PATCH v4 0/4] Allow SoundWire devices to communicate during remove Charles Keepax
2026-11-24 16:09 ` [PATCH v4 1/4] ASoC: SOF: Intel: Add IRQ chip to distribute the SoundWire IRQ Charles Keepax
2026-11-24 16:36 ` sashiko-bot
2026-11-24 16:49 ` Pierre-Louis Bossart
2026-11-24 16:09 ` [PATCH v4 2/4] soundwire: bus: Don't unassign dev_num before unregistering device Charles Keepax
2026-11-24 16:10 ` [PATCH v4 3/4] soundwire: bus: Expose a helper to remove devices from the bus Charles Keepax
2026-11-24 16:29 ` sashiko-bot
2026-11-24 16:10 ` [PATCH v4 4/4] soundwire: intel_auxdevice: Don't disable IRQs before removing children Charles Keepax
2026-11-24 16:27 ` 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-231558@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ckeepax@opensource.cirrus.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox