remoteproc: Check for NULL firmwares in sysfs interface
authorSuman Anna <s-anna@ti.com>
Sat, 15 Sep 2018 00:37:22 +0000 (19:37 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 24 Nov 2019 07:23:15 +0000 (08:23 +0100)
[ Upstream commit faeadbb64094757150a8c2a3175ca418dbdd472c ]

The remoteproc framework provides a sysfs file 'firmware'
for modifying the firmware image name from userspace. Add
an additional check to ensure NULL firmwares are errored
out right away, rather than getting a delayed error while
requesting a firmware during the start of a remoteproc
later on.

Tested-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/remoteproc/remoteproc_sysfs.c

index 47be411400e56aed1b48f44d4254e0178a640412..3a4c3d7cafca35f7752c9ddb402a643549be4050 100644 (file)
@@ -48,6 +48,11 @@ static ssize_t firmware_store(struct device *dev,
        }
 
        len = strcspn(buf, "\n");
+       if (!len) {
+               dev_err(dev, "can't provide a NULL firmware\n");
+               err = -EINVAL;
+               goto out;
+       }
 
        p = kstrndup(buf, len, GFP_KERNEL);
        if (!p) {