[PATCH v2 3/4] remoteproc: core: Guard against a missing stop() in the attach unwind

From: Yonghao Zhang

Date: Tue Nov 24 2026 - 02:15:00 EST


When the subdevice registration fails after a successful ops->attach(),
__rproc_attach() unrolls with an unconditional ops->stop() call: an
implementation without stop() turns that error path into a NULL
dereference.

An attach-only implementation, such as commit 1168af40b1ad ("remoteproc:
k3-r5: Add support for IPC-only mode for all R5Fs"), has no stop() and
can reach that path. Skip the rollback call when there is no stop():
with nothing to roll the attach back with, the processor stays running
and the failure is reported by the attach attempt itself.

Fixes: d848a4819d85 ("remoteproc: Introducing function rproc_attach()")
Signed-off-by: Yonghao Zhang <hyz3367@xxxxxxxxx>
---
drivers/remoteproc/remoteproc_core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index e44b45510b4e..8c3fc85b8f04 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -1357,7 +1357,10 @@ static int __rproc_attach(struct rproc *rproc)
if (ret) {
dev_err(dev, "failed to probe subdevices for %s: %d\n",
rproc->name, ret);
- goto stop_rproc;
+ if (rproc->ops->stop)
+ goto stop_rproc;
+ dev_err(dev, "can't roll %s back: no stop()\n", rproc->name);
+ goto unprepare_subdevices;
}

rproc->state = RPROC_ATTACHED;
--
2.34.1