* [PATCH] base: dd: fix error return code of driver_sysfs_add()
@ 2021-03-05 10:24 Jia-Ju Bai
2021-03-05 17:30 ` Rafael J. Wysocki
2021-03-23 13:57 ` Greg KH
0 siblings, 2 replies; 4+ messages in thread
From: Jia-Ju Bai @ 2021-03-05 10:24 UTC (permalink / raw)
To: gregkh, rafael; +Cc: linux-kernel, Jia-Ju Bai
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>
---
drivers/base/dd.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 9179825ff646..f94bbef95258 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -413,8 +413,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");
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] base: dd: fix error return code of driver_sysfs_add()
2021-03-05 10:24 [PATCH] base: dd: fix error return code of driver_sysfs_add() Jia-Ju Bai
@ 2021-03-05 17:30 ` Rafael J. Wysocki
2021-03-23 13:57 ` Greg KH
1 sibling, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2021-03-05 17:30 UTC (permalink / raw)
To: Jia-Ju Bai
Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Linux Kernel Mailing List
On Fri, Mar 5, 2021 at 11:24 AM Jia-Ju Bai <baijiaju1990@gmail.com> wrote:
>
> 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>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> drivers/base/dd.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index 9179825ff646..f94bbef95258 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -413,8 +413,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");
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] base: dd: fix error return code of driver_sysfs_add()
2021-03-05 10:24 [PATCH] base: dd: fix error return code of driver_sysfs_add() Jia-Ju Bai
2021-03-05 17:30 ` Rafael J. Wysocki
@ 2021-03-23 13:57 ` Greg KH
2021-03-24 2:33 ` Jia-Ju Bai
1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2021-03-23 13:57 UTC (permalink / raw)
To: Jia-Ju Bai; +Cc: rafael, linux-kernel
On Fri, Mar 05, 2021 at 02:24:05AM -0800, Jia-Ju Bai wrote:
> 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>
> ---
> drivers/base/dd.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index 9179825ff646..f94bbef95258 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -413,8 +413,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;
> +
Trailing whitespace :(
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] base: dd: fix error return code of driver_sysfs_add()
2021-03-23 13:57 ` Greg KH
@ 2021-03-24 2:33 ` Jia-Ju Bai
0 siblings, 0 replies; 4+ messages in thread
From: Jia-Ju Bai @ 2021-03-24 2:33 UTC (permalink / raw)
To: Greg KH; +Cc: rafael, linux-kernel
On 2021/3/23 21:57, Greg KH wrote:
> On Fri, Mar 05, 2021 at 02:24:05AM -0800, Jia-Ju Bai wrote:
>> 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>
>> ---
>> drivers/base/dd.c | 7 +++++--
>> 1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
>> index 9179825ff646..f94bbef95258 100644
>> --- a/drivers/base/dd.c
>> +++ b/drivers/base/dd.c
>> @@ -413,8 +413,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;
>> +
> Trailing whitespace :
Ah, sorry, I will send a V2 patch.
Best wishes,
Jia-Ju Bai
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-03-24 2:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-05 10:24 [PATCH] base: dd: fix error return code of driver_sysfs_add() Jia-Ju Bai
2021-03-05 17:30 ` Rafael J. Wysocki
2021-03-23 13:57 ` Greg KH
2021-03-24 2:33 ` Jia-Ju Bai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.