The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: Colin King <colin.king@canonical.com>
Cc: Sebastian Reichel <sre@kernel.org>,
	linux-pm@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] power: supply: cpcap-charger: Fix power_supply_put on null battery pointer
Date: Fri, 15 Jan 2021 15:24:17 +0200	[thread overview]
Message-ID: <YAGXgWeWvy/0FyqN@atomide.com> (raw)
In-Reply-To: <20210115131524.71339-1-colin.king@canonical.com>

* 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
> 

  reply	other threads:[~2021-01-15 13:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2021-01-15 14:32   ` Sebastian Reichel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YAGXgWeWvy/0FyqN@atomide.com \
    --to=tony@atomide.com \
    --cc=colin.king@canonical.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox