From patchwork Mon Aug 17 15:14:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 265992 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0EF24C433DF for ; Mon, 17 Aug 2020 19:28:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DEC6B204EC for ; Mon, 17 Aug 2020 19:28:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597692523; bh=3rH7cjEIsshVXwppVS5zdqv3B9dko9S6awy+zGLjnUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=HowxDrPorFeh1ve2GHO6z3YocMduv+zPQlDomJ2iErgdDfmlRI3xxyja3L2T8eNnW hKqTZCEBVlAWmtwvI1j1R1IejtoVxYba2rtzIJiwSc4Jr/pjd0cHTL2GyRZ6JZv1T6 UvJxxd79T03D9QA1KM0pBGbWBRjjdJ7Og4z1gAsg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731942AbgHQT2j (ORCPT ); Mon, 17 Aug 2020 15:28:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:60722 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730320AbgHQPcj (ORCPT ); Mon, 17 Aug 2020 11:32:39 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 50FBA23101; Mon, 17 Aug 2020 15:32:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597678353; bh=3rH7cjEIsshVXwppVS5zdqv3B9dko9S6awy+zGLjnUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X5OuWQEcgKwVHX92iuiMDBta6+6siBeePGqB9DH6Glc+33Nf0VJwoulNjXBx5DC7l 6z4YWu1UB0u30e9o3cGeD9zgXk+Lhw9XT2JhJSVAQQfiBMMQSAkUR5MQQr/e+Bi+T5 VkRoZYMgtWNke1KoUe0H5TmPFugjKH4xpQvdSN+Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tom Rix , Sebastian Reichel , Sasha Levin Subject: [PATCH 5.8 304/464] power: supply: check if calc_soc succeeded in pm860x_init_battery Date: Mon, 17 Aug 2020 17:14:17 +0200 Message-Id: <20200817143848.366989885@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143833.737102804@linuxfoundation.org> References: <20200817143833.737102804@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Tom Rix [ Upstream commit ccf193dee1f0fff55b556928591f7818bac1b3b1 ] clang static analysis flags this error 88pm860x_battery.c:522:19: warning: Assigned value is garbage or undefined [core.uninitialized.Assign] info->start_soc = soc; ^ ~~~ soc is set by calling calc_soc. But calc_soc can return without setting soc. So check the return status and bail similarly to other checks in pm860x_init_battery and initialize soc to silence the warning. Fixes: a830d28b48bf ("power_supply: Enable battery-charger for 88pm860x") Signed-off-by: Tom Rix Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin --- drivers/power/supply/88pm860x_battery.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/88pm860x_battery.c b/drivers/power/supply/88pm860x_battery.c index 1308f3a185f3d..590da88a17a25 100644 --- a/drivers/power/supply/88pm860x_battery.c +++ b/drivers/power/supply/88pm860x_battery.c @@ -433,7 +433,7 @@ static void pm860x_init_battery(struct pm860x_battery_info *info) int ret; int data; int bat_remove; - int soc; + int soc = 0; /* measure enable on GPADC1 */ data = MEAS1_GP1; @@ -496,7 +496,9 @@ static void pm860x_init_battery(struct pm860x_battery_info *info) } mutex_unlock(&info->lock); - calc_soc(info, OCV_MODE_ACTIVE, &soc); + ret = calc_soc(info, OCV_MODE_ACTIVE, &soc); + if (ret < 0) + goto out; data = pm860x_reg_read(info->i2c, PM8607_POWER_UP_LOG); bat_remove = data & BAT_WU_LOG;