From: Suman Anna Date: Sat, 15 Sep 2018 00:37:22 +0000 (-0500) Subject: remoteproc: Check for NULL firmwares in sysfs interface X-Git-Tag: rel_imx_5.10.35_2.0.0-somdevices.0~6020^2~25 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=faeadbb64094757150a8c2a3175ca418dbdd472c;p=linux.git remoteproc: Check for NULL firmwares in sysfs interface 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 Signed-off-by: Suman Anna Signed-off-by: Bjorn Andersson --- diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 47be411400e5..3a4c3d7cafca 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -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) {