summaryrefslogtreecommitdiff
path: root/drivers/remoteproc/remoteproc_sysfs.c
diff options
context:
space:
mode:
authorShengjiu Wang <shengjiu.wang@nxp.com>2022-03-28 05:20:12 +0300
committerMathieu Poirier <mathieu.poirier@linaro.org>2022-04-14 20:13:33 +0300
commit5e6a0e05270e3a4bb9289a0415d062966c27d192 (patch)
tree3775198a18e92b4de73c50d493a1c6b2ad193c5c /drivers/remoteproc/remoteproc_sysfs.c
parent8f454f950dbb663180f596db18c3dc7ec26497f0 (diff)
downloadlinux-5e6a0e05270e3a4bb9289a0415d062966c27d192.tar.xz
remoteproc: core: Move state checking to remoteproc_core
There is no mutex protection of these state checking for 'stop' and 'detach' which can't guarantee there is no another instance is trying to do same operation. Consider two instances case: Instance1: echo stop > /sys/class/remoteproc/remoteproc0/state Instance2: echo stop > /sys/class/remoteproc/remoteproc0/state The issue is that the instance2 case may success, Or it may fail with -EINVAL, which is uncertain. So move this state checking in rproc_cdev_write() and state_store() for 'stop', 'detach' operation to 'rproc_shutdown' , 'rproc_detach' function under the mutex protection. Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com> Link: https://lore.kernel.org/r/1648434012-16655-3-git-send-email-shengjiu.wang@nxp.com Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Diffstat (limited to 'drivers/remoteproc/remoteproc_sysfs.c')
-rw-r--r--drivers/remoteproc/remoteproc_sysfs.c7
1 files changed, 0 insertions, 7 deletions
diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c
index ac64d69085ab..8c7ea8922638 100644
--- a/drivers/remoteproc/remoteproc_sysfs.c
+++ b/drivers/remoteproc/remoteproc_sysfs.c
@@ -198,15 +198,8 @@ static ssize_t state_store(struct device *dev,
if (ret)
dev_err(&rproc->dev, "Boot failed: %d\n", ret);
} else if (sysfs_streq(buf, "stop")) {
- if (rproc->state != RPROC_RUNNING &&
- rproc->state != RPROC_ATTACHED)
- return -EINVAL;
-
ret = rproc_shutdown(rproc);
} else if (sysfs_streq(buf, "detach")) {
- if (rproc->state != RPROC_ATTACHED)
- return -EINVAL;
-
ret = rproc_detach(rproc);
} else {
dev_err(&rproc->dev, "Unrecognised option: %s\n", buf);