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

From: Jinpu Wang
Date: Thu Nov 26 2020 - 09:04:58 EST


On Wed, Nov 25, 2020 at 1:47 PM Wang ShaoBo <bobo.shaobowang@xxxxxxxxxx> 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 <bobo.shaobowang@xxxxxxxxxx>
Thanks Shaobo, we have a fix for more cases:
https://lore.kernel.org/linux-block/20201126104723.150674-8-jinpu.wang@xxxxxxxxxxxxxxx/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
>