From patchwork Thu Aug 20 09:21:50 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: 265523 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=unavailable 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 7C81AC433E3 for ; Thu, 20 Aug 2020 11:54:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58DBF207BB for ; Thu, 20 Aug 2020 11:54:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597924498; bh=yFQbJc/EOVgnddYLEayofDZFETxGTAIux4q8PSfvB3E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=mz8ht96EYPmKSm78S3L9XjQWkq0cv4tCMr4Gov2jxwTvtCTk9N2X6u7El39WCpHEh 99qmgEREWyXhzeToMGVi2dB/xt/RHBCVrDmA4wPvSS0/aj7Q8vJzB+eCvOlvOuu1Td uMYOqMR2E4ik1lktmt/9gBCzTFk/JnKdhNSTOLws= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729392AbgHTLs1 (ORCPT ); Thu, 20 Aug 2020 07:48:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:56284 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730046AbgHTKDe (ORCPT ); Thu, 20 Aug 2020 06:03:34 -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 70BCA22B43; Thu, 20 Aug 2020 10:03:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597917814; bh=yFQbJc/EOVgnddYLEayofDZFETxGTAIux4q8PSfvB3E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0RwwNzp46uYliqIWDkbC8pBv6d359uSQ1n8ara9n8lmyGmJrlP3n7/0Alj1t5SH3K L9f1p01yNGHmhZk/jN2rR6mcJLo0j7k198w7bhvj6+k4gpuK7+tDDO5It5w5xEZwFz ncJ99J/8QlcMfldWPW8dy/6qvmtjdypIq+EGf67Q= 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 4.9 137/212] power: supply: check if calc_soc succeeded in pm860x_init_battery Date: Thu, 20 Aug 2020 11:21:50 +0200 Message-Id: <20200820091609.273818389@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091602.251285210@linuxfoundation.org> References: <20200820091602.251285210@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 63c57dc82ac1d..4eda5065b5bbc 100644 --- a/drivers/power/supply/88pm860x_battery.c +++ b/drivers/power/supply/88pm860x_battery.c @@ -436,7 +436,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; @@ -499,7 +499,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;