mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] remoteproc: k3-r5: Fix driver shutdown
@ 2024-08-19 16:47 Jan Kiszka
  2024-08-20  9:30 ` Beleswar Prasad Padhi
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Kiszka @ 2024-08-19 16:47 UTC (permalink / raw)
  To: Bjorn Andersson, Mathieu Poirier, linux-remoteproc
  Cc: Linux Kernel Mailing List, Apurva Nandan, Beleswar Padhi, stable,
	Nishanth Menon

From: Jan Kiszka <jan.kiszka@siemens.com>

When k3_r5_cluster_rproc_exit is run, core 1 is shutdown and removed
first. When core 0 should then be stopped before its removal, it will
find core1->rproc as NULL already and crashes. Happens on rmmod e.g.

Fixes: 3c8a9066d584 ("remoteproc: k3-r5: Do not allow core1 to power up before core0 via sysfs")
CC: stable@vger.kernel.org
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

There might be one more because I can still make this driver crash 
after an operator error. Were error scenarios tested at all?

 drivers/remoteproc/ti_k3_r5_remoteproc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/ti_k3_r5_remoteproc.c
index eb09d2e9b32a..9ebd7a34e638 100644
--- a/drivers/remoteproc/ti_k3_r5_remoteproc.c
+++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c
@@ -646,7 +646,8 @@ static int k3_r5_rproc_stop(struct rproc *rproc)
 		/* do not allow core 0 to stop before core 1 */
 		core1 = list_last_entry(&cluster->cores, struct k3_r5_core,
 					elem);
-		if (core != core1 && core1->rproc->state != RPROC_OFFLINE) {
+		if (core != core1 && core1->rproc &&
+		    core1->rproc->state != RPROC_OFFLINE) {
 			dev_err(dev, "%s: can not stop core 0 before core 1\n",
 				__func__);
 			ret = -EPERM;
-- 
2.43.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-08-20 15:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-19 16:47 [PATCH] remoteproc: k3-r5: Fix driver shutdown Jan Kiszka
2024-08-20  9:30 ` Beleswar Prasad Padhi
2024-08-20  9:39   ` Jan Kiszka
2024-08-20  9:48     ` Beleswar Prasad Padhi
2024-08-20 14:20       ` Jan Kiszka
2024-08-20 14:59         ` Beleswar Prasad Padhi
2024-08-20 15:15           ` Beleswar Prasad Padhi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®