* [PATCH][next] power: supply: cpcap-charger: Fix power_supply_put on null battery pointer
@ 2021-01-15 13:15 Colin King
2021-01-15 13:24 ` Tony Lindgren
0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2021-01-15 13:15 UTC (permalink / raw)
To: Sebastian Reichel, Tony Lindgren, linux-pm; +Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Currently if the pointer battery is null there is a null pointer
dereference on the call to power_supply_put. Fix this by only
performing the put if battery is not null.
Addresses-Coverity: ("Dereference after null check")
Fixes: 4bff91bb3231 ("power: supply: cpcap-charger: Fix missing power_supply_put()")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/power/supply/cpcap-charger.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/power/supply/cpcap-charger.c b/drivers/power/supply/cpcap-charger.c
index 823d666f09e0..641dcad1133f 100644
--- a/drivers/power/supply/cpcap-charger.c
+++ b/drivers/power/supply/cpcap-charger.c
@@ -300,8 +300,9 @@ cpcap_charger_get_bat_const_charge_voltage(struct cpcap_charger_ddata *ddata)
&prop);
if (!error)
voltage = prop.intval;
+
+ power_supply_put(battery);
}
- power_supply_put(battery);
return voltage;
}
--
2.29.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH][next] power: supply: cpcap-charger: Fix power_supply_put on null battery pointer
2021-01-15 13:15 [PATCH][next] power: supply: cpcap-charger: Fix power_supply_put on null battery pointer Colin King
@ 2021-01-15 13:24 ` Tony Lindgren
2021-01-15 14:32 ` Sebastian Reichel
0 siblings, 1 reply; 3+ messages in thread
From: Tony Lindgren @ 2021-01-15 13:24 UTC (permalink / raw)
To: Colin King; +Cc: Sebastian Reichel, linux-pm, kernel-janitors, linux-kernel
* Colin King <colin.king@canonical.com> [210115 13:15]:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently if the pointer battery is null there is a null pointer
> dereference on the call to power_supply_put. Fix this by only
> performing the put if battery is not null.
>
> Addresses-Coverity: ("Dereference after null check")
> Fixes: 4bff91bb3231 ("power: supply: cpcap-charger: Fix missing power_supply_put()")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Oopsie, thanks for fixing it:
Acked-by: Tony Lindgren <tony@atomide.com>
> drivers/power/supply/cpcap-charger.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/power/supply/cpcap-charger.c b/drivers/power/supply/cpcap-charger.c
> index 823d666f09e0..641dcad1133f 100644
> --- a/drivers/power/supply/cpcap-charger.c
> +++ b/drivers/power/supply/cpcap-charger.c
> @@ -300,8 +300,9 @@ cpcap_charger_get_bat_const_charge_voltage(struct cpcap_charger_ddata *ddata)
> &prop);
> if (!error)
> voltage = prop.intval;
> +
> + power_supply_put(battery);
> }
> - power_supply_put(battery);
>
> return voltage;
> }
> --
> 2.29.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][next] power: supply: cpcap-charger: Fix power_supply_put on null battery pointer
2021-01-15 13:24 ` Tony Lindgren
@ 2021-01-15 14:32 ` Sebastian Reichel
0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Reichel @ 2021-01-15 14:32 UTC (permalink / raw)
To: Tony Lindgren; +Cc: Colin King, linux-pm, kernel-janitors, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1383 bytes --]
Hi,
On Fri, Jan 15, 2021 at 03:24:17PM +0200, Tony Lindgren wrote:
> * Colin King <colin.king@canonical.com> [210115 13:15]:
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > Currently if the pointer battery is null there is a null pointer
> > dereference on the call to power_supply_put. Fix this by only
> > performing the put if battery is not null.
> >
> > Addresses-Coverity: ("Dereference after null check")
> > Fixes: 4bff91bb3231 ("power: supply: cpcap-charger: Fix missing power_supply_put()")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
>
> Oopsie, thanks for fixing it:
>
> Acked-by: Tony Lindgren <tony@atomide.com>
Thanks, queued.
-- Sebastian
> > drivers/power/supply/cpcap-charger.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/power/supply/cpcap-charger.c b/drivers/power/supply/cpcap-charger.c
> > index 823d666f09e0..641dcad1133f 100644
> > --- a/drivers/power/supply/cpcap-charger.c
> > +++ b/drivers/power/supply/cpcap-charger.c
> > @@ -300,8 +300,9 @@ cpcap_charger_get_bat_const_charge_voltage(struct cpcap_charger_ddata *ddata)
> > &prop);
> > if (!error)
> > voltage = prop.intval;
> > +
> > + power_supply_put(battery);
> > }
> > - power_supply_put(battery);
> >
> > return voltage;
> > }
> > --
> > 2.29.2
> >
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-15 14:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-15 13:15 [PATCH][next] power: supply: cpcap-charger: Fix power_supply_put on null battery pointer Colin King
2021-01-15 13:24 ` Tony Lindgren
2021-01-15 14:32 ` Sebastian Reichel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).