Re: [PATCH] net-sysfs: Fix memory leak in netdev_register_kobject
From: Stephen Hemminger
Date: Tue Mar 19 2019 - 11:45:01 EST
On Tue, 19 Mar 2019 20:17:01 +0800
"wanghai (M)" <wanghai26@xxxxxxxxxx> wrote:
> +out:
> ÂÂÂÂÂÂÂ return error;
> +register_error:
> +ÂÂÂÂÂÂ device_del(dev);
> +device_add_error:
> +ÂÂÂÂÂÂ put_device(dev);
> +ÂÂÂÂÂÂ goto out;
Everything looks fine, but I would redo the last part without
the last goto out. Using a goto back to single return reduces
readability.
if (error)
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂ goto register_error;
ÂÂÂÂÂÂÂ
pm_runtime_set_memalloc_noio(dev, true);
return 0;
register_error:
ÂÂÂÂÂ device_del(dev);
device_add_error:
ÂÂÂÂÂÂ put_device(dev);
ÂÂÂÂÂÂ return error;