Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1689911pxb; Thu, 16 Sep 2021 13:04:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7h1rOpWQuVcXbOWfQTaSSWVagLAm+wEHQ4GZov412UGW6Cj/Pw8zvB5mPFuj0dfBdeCn+ X-Received: by 2002:a92:730c:: with SMTP id o12mr5198543ilc.208.1631822646149; Thu, 16 Sep 2021 13:04:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631822646; cv=none; d=google.com; s=arc-20160816; b=IMIjVoWjowM68Avcc3I260SANIRh1C4aKb+w+AG+iHlBu6KXxzjYcPF5wxWLmUbIMd HMf83dzp8YWC61ziuJoEHS1SuXZCKF0sPuAkPFm12P38yLodYYFDLUp3JcexHaBt/dOH 05UUXymqWompmZfhGQ0tMrmh8ddQc4swQipZsW5irgpULXSVVRTcEYxeRVk8lcxbVroR NrxCBrEYgQyCRdI57SwgrhM6KZcNAfCUjacyFwtLu4SfFUqbbTf45fxKGbh/GQN76vIL GiZQK2gvKJ4rJrZm9BcD6fK7Xds4wZ0G6bAVpeaTHeTBhpcnnawOso39bXNbhxQOqhLY XKng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AggO7cL1BKCDNP1/i9tnj+ybUVBretYZAlielpqGKbk=; b=1JNqNwYPO7hQBKpvrD0xrYON8456XXp9+3Jcx7+exgd4yDIZTSh4qcuooNThWZ0JMv ffp6lcO5h4zfV5Hf3LSNnOhscI9lMeLklsdKKMXWUKVoV21k6vKbtCu7rkabgRQMXCN1 L9qhsmsiRPF94sDMsXRgVdOMAHvm7v6tExSh/bwuIiMJUcFXESBv+7r1PojgFNhT4rDA r4HfORRP41j9qF3JzBMsPPMY1HALdSxRrhGkYJBeI71HvFwHowRXMynhijUcRpZxR8wD SrJ5sFuGwM6eQuxdxurulYkPk2erG4TsLxrphSTtzoTMCv1DTrxLtNXCJ4GxZCq7AxYX vKJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qpoFifMH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s7si3454849ilp.105.2021.09.16.13.03.48; Thu, 16 Sep 2021 13:04:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qpoFifMH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233390AbhIPQNL (ORCPT + 99 others); Thu, 16 Sep 2021 12:13:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:47920 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233807AbhIPQHy (ORCPT ); Thu, 16 Sep 2021 12:07:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 604E160698; Thu, 16 Sep 2021 16:06:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808393; bh=79xhAtAG4uraJRRzv9q5qPYfaK+BTkpQn7ioYrexVes=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qpoFifMHCTh4iGmxvhC1B1imOJ/kAH4Rp7dSG+4LG3X7xArIvFCEYRPME77pqTjJB dHRPGagwGRCUDhIRpprkztPfFt8e/9VB9cWU1dAEXv7ITMzCA/Gin/9gFK7T596CHS 5OuFTcNloIpj10J6qqHYmei7nSW2UmCpH92qE+VQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Krzysztof Kozlowski , Hans de Goede , Sebastian Reichel Subject: [PATCH 5.10 032/306] power: supply: max17042: handle fails of reading status register Date: Thu, 16 Sep 2021 17:56:17 +0200 Message-Id: <20210916155755.035084928@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Krzysztof Kozlowski commit 54784ffa5b267f57161eb8fbb811499f22a0a0bf upstream. Reading status register can fail in the interrupt handler. In such case, the regmap_read() will not store anything useful under passed 'val' variable and random stack value will be used to determine type of interrupt. Handle the regmap_read() failure to avoid handling interrupt type and triggering changed power supply event based on random stack value. Fixes: 39e7213edc4f ("max17042_battery: Support regmap to access device's registers") Cc: Signed-off-by: Krzysztof Kozlowski Reviewed-by: Hans de Goede Signed-off-by: Sebastian Reichel Signed-off-by: Greg Kroah-Hartman --- drivers/power/supply/max17042_battery.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/drivers/power/supply/max17042_battery.c +++ b/drivers/power/supply/max17042_battery.c @@ -859,8 +859,12 @@ static irqreturn_t max17042_thread_handl { struct max17042_chip *chip = dev; u32 val; + int ret; + + ret = regmap_read(chip->regmap, MAX17042_STATUS, &val); + if (ret) + return IRQ_HANDLED; - regmap_read(chip->regmap, MAX17042_STATUS, &val); if ((val & STATUS_INTR_SOCMIN_BIT) || (val & STATUS_INTR_SOCMAX_BIT)) { dev_info(&chip->client->dev, "SOC threshold INTR\n");