[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJZ5v0g5vy4PDVGTso+cV1Zz1LvtUN7OsgWntVAFv9pr0a=6mA@mail.gmail.com>
Date: Fri, 5 Mar 2021 18:30:07 +0100
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Jia-Ju Bai <baijiaju1990@...il.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] base: dd: fix error return code of driver_sysfs_add()
On Fri, Mar 5, 2021 at 11:24 AM Jia-Ju Bai <baijiaju1990@...il.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@...nghua.edu.cn>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@...il.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@...el.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
>
Powered by blists - more mailing lists