2020-11-25 12:50:52

by Wangshaobo (bobo)

[permalink] [raw]
Subject: [PATCH] block/rnbd: server: Fix error return code in rnbd_srv_create_dev_sysfs()

Fix to return -ENOMEM error code from the error handling case where
kobject_create_and_add() failed instead of 0 in rnbd_srv_create_dev_sysfs(),
as done elsewhere in this function.

Signed-off-by: Wang ShaoBo <[email protected]>
---
drivers/block/rnbd/rnbd-srv-sysfs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/block/rnbd/rnbd-srv-sysfs.c b/drivers/block/rnbd/rnbd-srv-sysfs.c
index 106775c074d1..5ba1a31ad626 100644
--- a/drivers/block/rnbd/rnbd-srv-sysfs.c
+++ b/drivers/block/rnbd/rnbd-srv-sysfs.c
@@ -52,8 +52,10 @@ int rnbd_srv_create_dev_sysfs(struct rnbd_srv_dev *dev,

dev->dev_sessions_kobj = kobject_create_and_add("sessions",
&dev->dev_kobj);
- if (!dev->dev_sessions_kobj)
+ if (!dev->dev_sessions_kobj) {
+ ret = -ENOMEM;
goto put_dev_kobj;
+ }

bdev_kobj = &disk_to_dev(bdev->bd_disk)->kobj;
ret = sysfs_create_link(&dev->dev_kobj, bdev_kobj, "block_dev");
--
2.17.1


2020-11-26 14:08:03

by Jinpu Wang

[permalink] [raw]
Subject: Re: [PATCH] block/rnbd: server: Fix error return code in rnbd_srv_create_dev_sysfs()

On Wed, Nov 25, 2020 at 1:47 PM Wang ShaoBo <[email protected]> wrote:
>
> Fix to return -ENOMEM error code from the error handling case where
> kobject_create_and_add() failed instead of 0 in rnbd_srv_create_dev_sysfs(),
> as done elsewhere in this function.
>
> Signed-off-by: Wang ShaoBo <[email protected]>
Thanks Shaobo, we have a fix for more cases:
https://lore.kernel.org/linux-block/[email protected]/T/#u
> ---
> drivers/block/rnbd/rnbd-srv-sysfs.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/block/rnbd/rnbd-srv-sysfs.c b/drivers/block/rnbd/rnbd-srv-sysfs.c
> index 106775c074d1..5ba1a31ad626 100644
> --- a/drivers/block/rnbd/rnbd-srv-sysfs.c
> +++ b/drivers/block/rnbd/rnbd-srv-sysfs.c
> @@ -52,8 +52,10 @@ int rnbd_srv_create_dev_sysfs(struct rnbd_srv_dev *dev,
>
> dev->dev_sessions_kobj = kobject_create_and_add("sessions",
> &dev->dev_kobj);
> - if (!dev->dev_sessions_kobj)
> + if (!dev->dev_sessions_kobj) {
> + ret = -ENOMEM;
> goto put_dev_kobj;
> + }
>
> bdev_kobj = &disk_to_dev(bdev->bd_disk)->kobj;
> ret = sysfs_create_link(&dev->dev_kobj, bdev_kobj, "block_dev");
> --
> 2.17.1
>