[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CACRpkdaTmWomZY6WgozTJKVMvTmesDRsLqhn5BP+QeaMoAA1VA@mail.gmail.com>
Date: Sat, 29 Jan 2022 01:53:42 +0100
From: Linus Walleij <linus.walleij@...aro.org>
To: Miaoqian Lin <linmq006@...il.com>
Cc: Sebastian Reichel <sre@...nel.org>, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] power: supply: ab8500: Fix memory leak in ab8500_chargalg_sysfs_init
On Fri, Jan 28, 2022 at 6:33 PM Miaoqian Lin <linmq006@...il.com> 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 this issue by adding kobject_put().
>
> Fixes: c5b64a990e7f ("power: supply: ab8500: Rename charging algorithm symbols")
Really? I think this code is older.
> @@ -1907,8 +1907,10 @@ static int ab8500_chargalg_sysfs_init(struct ab8500_chargalg *di)
> ret = kobject_init_and_add(&di->chargalg_kobject,
> &ab8500_chargalg_ktype,
> NULL, "ab8500_chargalg");
> - if (ret < 0)
> + if (ret < 0) {
> dev_err(di->dev, "failed to create sysfs entry\n");
> + kobject_put(&di->chargalg_kobject);
> + }
I wouldn't bother with this.
This code is getting deleted in this patch:
https://lore.kernel.org/linux-pm/20220129004925.639684-10-linus.walleij@linaro.org/T/#u
Yours,
Linus Walleij
Powered by blists - more mailing lists