lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 11 Feb 2022 21:04:04 +0100
From:   Sebastian Reichel <sebastian.reichel@...labora.com>
To:     Miaoqian Lin <linmq006@...il.com>
Cc:     linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
        Linus Walleij <linus.walleij@...aro.org>
Subject: Re: [PATCH] power: supply: ab8500: Fix memory leak in
 ab8500_fg_sysfs_init

[+cc Linus Walleij]

Hi,

On Mon, Jan 24, 2022 at 01:13:46PM +0000, Miaoqian Lin wrote:
> kobject_init_and_add() takes reference even when it fails.
> According to the doc of kobject_init_and_add():
> 
>    If this function returns an error, kobject_put() must be called to
>    properly clean up the memory associated with the object.
> 
> Fix memory leak by calling kobject_put().
> 
> Fixes: 8c0984e5a753 ("power: move power supply drivers to power/supply")
> Signed-off-by: Miaoqian Lin <linmq006@...il.com>
> ---

Thanks, queued power-supply's for-next branch.

Linus, if I'm not mistaken the custom sysfs ABI (i.e. everything related
to ab8500_fg_sysfs_init() can just be removed since the same thing is
already exposed standardized via POWER_SUPPLY_PROP_CHARGE_FULL and
POWER_SUPPLY_PROP_CHARGE_NOW?

-- Sebastian

>  drivers/power/supply/ab8500_fg.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c
> index 05fe9724ba50..57799a8079d4 100644
> --- a/drivers/power/supply/ab8500_fg.c
> +++ b/drivers/power/supply/ab8500_fg.c
> @@ -2545,8 +2545,10 @@ static int ab8500_fg_sysfs_init(struct ab8500_fg *di)
>  	ret = kobject_init_and_add(&di->fg_kobject,
>  		&ab8500_fg_ktype,
>  		NULL, "battery");
> -	if (ret < 0)
> +	if (ret < 0) {
> +		kobject_put(&di->fg_kobject);
>  		dev_err(di->dev, "failed to create sysfs entry\n");
> +	}
>  
>  	return ret;
>  }
> -- 
> 2.17.1
> 

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ