[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <2025011012-placate-gracious-8cb4@gregkh>
Date: Fri, 10 Jan 2025 15:31:56 +0100
From: Greg KH <gregkh@...uxfoundation.org>
To: Yaxiong Tian <tianyaxiong@...inos.cn>
Cc: rafael@...nel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drivers core: bus: Remove unnecessary NULL assignments
in the bus_register() function
On Fri, Nov 29, 2024 at 11:01:30AM +0800, Yaxiong Tian wrote:
> In bus_register(), Priv is a local pointer variable, so its assignment
> can be ignored and the function can be returned directly. This can reduce
> the NULL checks in the subsequent kfree function.
>
> Signed-off-by: Yaxiong Tian <tianyaxiong@...inos.cn>
> ---
> drivers/base/bus.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/base/bus.c b/drivers/base/bus.c
> index 657c93c38b0d..c1fd2860e397 100644
> --- a/drivers/base/bus.c
> +++ b/drivers/base/bus.c
> @@ -923,7 +923,7 @@ int bus_register(const struct bus_type *bus)
> bus_uevent_fail:
> kset_unregister(&priv->subsys);
> /* Above kset_unregister() will kfree @priv */
> - priv = NULL;
> + return retval;
> out:
> kfree(priv);
> return retval;
The goal here was to fall down through the out: block, which is why priv
was set to NULL. So the code is correct as-is, no need to change
anything here as that would just be a preference change from what the
original author wanted with no functional change at all.
thanks,
greg k-h
Powered by blists - more mailing lists