public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] remoteproc: core: check rproc->power value before decreasing it
@ 2022-03-18  9:51 Shengjiu Wang
  2022-03-24 15:47 ` Mathieu Poirier
  0 siblings, 1 reply; 2+ messages in thread
From: Shengjiu Wang @ 2022-03-18  9:51 UTC (permalink / raw)
  To: bjorn.andersson, mathieu.poirier
  Cc: linux-remoteproc, linux-kernel, shengjiu.wang

There are possibility that two 'stop' operation happen
in parallel, then the rproc->power may be decreased to
-1, that this reference count will be in wrong state.
So check rproc->power to make sure it is larger than
zero before decreasing it.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
---
 drivers/remoteproc/remoteproc_core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index c510125769b9..84e065ad8743 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -2075,6 +2075,9 @@ int rproc_shutdown(struct rproc *rproc)
 		return ret;
 	}
 
+	if (atomic_read(&rproc->power) <= 0)
+		goto out;
+
 	/* if the remote proc is still needed, bail out */
 	if (!atomic_dec_and_test(&rproc->power))
 		goto out;
-- 
2.17.1


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

end of thread, other threads:[~2022-03-24 15:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-18  9:51 [PATCH] remoteproc: core: check rproc->power value before decreasing it Shengjiu Wang
2022-03-24 15:47 ` Mathieu Poirier

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