From 69756f277e10d7da4852e5b8555a7f7e9df6ae52 Mon Sep 17 00:00:00 2001 From: Bowen Wang Date: Fri, 16 Jun 2023 09:35:14 +0800 Subject: [PATCH] rptun_dump: do not acquire the lock when has hold the lock Otherwise, system will crash again when call rptun_dump_all() after has acquired the lock. Signed-off-by: Bowen Wang --- drivers/rptun/rptun_dump.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/rptun/rptun_dump.c b/drivers/rptun/rptun_dump.c index c490603483..9061569e08 100644 --- a/drivers/rptun/rptun_dump.c +++ b/drivers/rptun/rptun_dump.c @@ -94,13 +94,20 @@ void rptun_dump(FAR struct rpmsg_virtio_device *rvdev) FAR struct rpmsg_device *rdev = &rvdev->rdev; FAR struct rpmsg_endpoint *ept; FAR struct metal_list *node; + bool needlock = true; if (!rvdev->vdev) { return; } - if (!up_interrupt_context() && !sched_idletask()) + if (up_interrupt_context() || sched_idletask() || + nxmutex_is_hold(&rdev->lock)) + { + needlock = false; + } + + if (needlock) { metal_mutex_acquire(&rdev->lock); } @@ -128,7 +135,7 @@ void rptun_dump(FAR struct rpmsg_virtio_device *rvdev) rptun_dump_buffer(rvdev, true); rptun_dump_buffer(rvdev, false); - if (!up_interrupt_context() && !sched_idletask()) + if (needlock) { metal_mutex_release(&rdev->lock); }