Skip to content

Commit 35bdafd

Browse files
arnopomathieupoirier
authored andcommitted
remoteproc: stm32_rproc: Add mutex protection for workqueue
The workqueue may execute late even after remoteproc is stopped or stopping, some resources (rpmsg device and endpoint) have been released in rproc_stop_subdevices(), then rproc_vq_interrupt() accessing these resources will cause kernel dump. Call trace: virtqueue_add_inbuf virtqueue_add_inbuf rpmsg_recv_single rpmsg_recv_done vring_interrupt stm32_rproc_mb_vq_work process_one_work worker_thread kthread Suggested-by: Mathieu Poirier <mathieu.poirier@linaro.org> Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com> Link: https://lore.kernel.org/r/20230331160634.3113031-1-arnaud.pouliquen@foss.st.com Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
1 parent 8666071 commit 35bdafd

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

drivers/remoteproc/stm32_rproc.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,16 @@ static void stm32_rproc_mb_vq_work(struct work_struct *work)
291291
struct stm32_mbox *mb = container_of(work, struct stm32_mbox, vq_work);
292292
struct rproc *rproc = dev_get_drvdata(mb->client.dev);
293293

294+
mutex_lock(&rproc->lock);
295+
296+
if (rproc->state != RPROC_RUNNING)
297+
goto unlock_mutex;
298+
294299
if (rproc_vq_interrupt(rproc, mb->vq_id) == IRQ_NONE)
295300
dev_dbg(&rproc->dev, "no message found in vq%d\n", mb->vq_id);
301+
302+
unlock_mutex:
303+
mutex_unlock(&rproc->lock);
296304
}
297305

298306
static void stm32_rproc_mb_callback(struct mbox_client *cl, void *data)

0 commit comments

Comments
 (0)