From: Shengjiu Wang <shengjiu.wang@nxp.com>
To: bjorn.andersson@linaro.org, mathieu.poirier@linaro.org
Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org,
shengjiu.wang@gmail.com
Subject: [PATCH] remoteproc: core: check rproc->power value before decreasing it
Date: Fri, 18 Mar 2022 17:51:36 +0800 [thread overview]
Message-ID: <1647597096-5480-1-git-send-email-shengjiu.wang@nxp.com> (raw)
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
next reply other threads:[~2022-03-18 10:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-18 9:51 Shengjiu Wang [this message]
2022-03-24 15:47 ` Mathieu Poirier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1647597096-5480-1-git-send-email-shengjiu.wang@nxp.com \
--to=shengjiu.wang@nxp.com \
--cc=bjorn.andersson@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=shengjiu.wang@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®