Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Jia-Ju Bai and committed by
Greg Kroah-Hartman
d225ef6f e611f8cd

+5 -2
+5 -2
drivers/base/dd.c
··· 415 415 if (ret) 416 416 goto rm_dev; 417 417 418 - if (!IS_ENABLED(CONFIG_DEV_COREDUMP) || !dev->driver->coredump || 419 - !device_create_file(dev, &dev_attr_coredump)) 418 + if (!IS_ENABLED(CONFIG_DEV_COREDUMP) || !dev->driver->coredump) 419 + return 0; 420 + 421 + ret = device_create_file(dev, &dev_attr_coredump); 422 + if (!ret) 420 423 return 0; 421 424 422 425 sysfs_remove_link(&dev->kobj, "driver");