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] [day] [month] [year] [list]
Date:   Mon, 5 Dec 2022 23:25:34 +0100
From:   Sebastian Reichel <sebastian.reichel@...labora.com>
To:     Baolin Wang <baolin.wang@...ux.alibaba.com>
Cc:     ruanjinjie <ruanjinjie@...wei.com>, linus.walleij@...aro.org,
        linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] power: supply: fix null pointer dereferencing in
 power_supply_get_battery_info

Hi,

On Mon, Dec 05, 2022 at 07:05:04PM +0800, Baolin Wang wrote:
> On 12/5/2022 3:51 PM, ruanjinjie wrote:
> > when kmalloc() fail to allocate memory in kasprintf(), propname
> > will be NULL, strcmp() called by of_get_property() will cause
> > null pointer dereference.
> > 
> > So return ENOMEM if kasprintf() return NULL pointer.
> > 
> > Fixes: 3afb50d7125b ("power: supply: core: Add some helpers to use the battery OCV capacity table")
> > Signed-off-by: ruanjinjie <ruanjinjie@...wei.com>
> 
> LGTM.
> Reviewed-by: Baolin Wang <baolin.wang@...ux.alibaba.com>

Thanks, queued.

-- Sebastian

> 
> > ---
> > v2:
> > - release resource instead of just returning error number
> > ---
> >   drivers/power/supply/power_supply_core.c | 5 +++++
> >   1 file changed, 5 insertions(+)
> > 
> > diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
> > index 4b5fb172fa99..afbe9eecfc30 100644
> > --- a/drivers/power/supply/power_supply_core.c
> > +++ b/drivers/power/supply/power_supply_core.c
> > @@ -750,6 +750,11 @@ int power_supply_get_battery_info(struct power_supply *psy,
> >   		int i, tab_len, size;
> >   		propname = kasprintf(GFP_KERNEL, "ocv-capacity-table-%d", index);
> > +		if (!propname) {
> > +			power_supply_put_battery_info(psy, info);
> > +			err = -ENOMEM;
> > +			goto out_put_node;
> > +		}
> >   		list = of_get_property(battery_np, propname, &size);
> >   		if (!list || !size) {
> >   			dev_err(&psy->dev, "failed to get %s\n", propname);

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