summaryrefslogtreecommitdiff
path: root/drivers/base
diff options
context:
space:
mode:
authorJia-Ju Bai <baijiaju1990@gmail.com>2021-03-23 19:34:05 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-03-28 14:55:39 +0200
commitd225ef6fda7ce9ff7d28764bd1cceea2d0215e8b (patch)
tree408e64150fbfc7bf0f1a5701d56d3fbcc3adc6bd /drivers/base
parente611f8cd8717c8fe7d4229997e6cd029a1465253 (diff)
downloadlwn-d225ef6fda7ce9ff7d28764bd1cceea2d0215e8b.tar.gz
lwn-d225ef6fda7ce9ff7d28764bd1cceea2d0215e8b.zip
base: dd: fix error return code of driver_sysfs_add()
When device_create_file() fails and returns a non-zero value, no error return code of driver_sysfs_add() is assigned. To fix this bug, ret is assigned with the return value of device_create_file(), and then ret is checked. Reported-by: TOTE Robot <oslab@tsinghua.edu.cn> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com> Link: https://lore.kernel.org/r/20210324023405.12465-1-baijiaju1990@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/dd.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index dd327cfd6843..20b69b5e0e91 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -415,8 +415,11 @@ static int driver_sysfs_add(struct device *dev)
if (ret)
goto rm_dev;
- if (!IS_ENABLED(CONFIG_DEV_COREDUMP) || !dev->driver->coredump ||
- !device_create_file(dev, &dev_attr_coredump))
+ if (!IS_ENABLED(CONFIG_DEV_COREDUMP) || !dev->driver->coredump)
+ return 0;
+
+ ret = device_create_file(dev, &dev_attr_coredump);
+ if (!ret)
return 0;
sysfs_remove_link(&dev->kobj, "driver");