Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2330608pxb; Mon, 20 Sep 2021 19:05:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDNsgp1pgCJ0eSkNk0oKl5FbWQuWE0Ak9hqWxTLIJYRnAAHLXIFGBIoEgLDKxHkdq7sJyM X-Received: by 2002:a17:906:ece4:: with SMTP id qt4mr32191230ejb.250.1632189915118; Mon, 20 Sep 2021 19:05:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632189915; cv=none; d=google.com; s=arc-20160816; b=HhYlKwVZyanp2nNjD3OgaQdoN43B56YEuQifiIWZV6ubjbN+j07W/3fJPdo4b7LCl/ K5KzNgGj9yBaFy/VGf3ALdvCGBd+EBLuuPxE96fe+/mUmUGPLarL4Pvc30PZaYLV4Qjv sHWigPvvoUBITs3TJ7CIesLvYbk71viWLiUeH25YO+Y5UDB9ZuS36JQFalXgOf2tZail Gx8vFGYQ9c+FDv1Gu5S8SzR+t7+LEFaqdwT4CDn3QMA+16hF1ygziIMmlgnZp1JCWuv6 A5ooz40B1CbRTdguffKxr+6A+zqqGHf36HCwP1gfn5Pc6BmPFRIbRWjMnVhmdtpafULW xm0Q== 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=boHNzXQ6Rb9HnbKUQ65t/70IVKiPJmZuUJSjxy/k/3s=; b=WS9x6UKrz0l1hMHnehO2Y+fGv9+A0D9ilu7SWt52yRqLky7SP8RPsUlrrADSsbR4Bh Nw9Fq3OgZz9HXZN4/qGNXnKzXOtzc5H3HlPseXvo/CQHp8RBqhLhjK4nKHXy+mQL7AV0 5TNhwzKyba6hf2Ylw0Gqn3xLIy8p/pPkV45kihHVGY17lls+C5obMJ+gRrGdTAacCyLF 0mZBQkttVEuecr6dTKp4xMoXK/Yvsq0S1njnosBLprtvRgbL5GgFXjPFXliGAnHv1oRL xMmDkJLpGu1hsKaL5lkI1LSlZ/8R1UKDEQvwnwFh2nls8xVMrR+Lr+RahfCazlh+K9TV aG4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zwvAWI6f; 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 a9si11256790edj.313.2021.09.20.19.04.50; Mon, 20 Sep 2021 19:05:15 -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=zwvAWI6f; 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 S1359546AbhITSKC (ORCPT + 99 others); Mon, 20 Sep 2021 14:10:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:60150 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357322AbhITSDz (ORCPT ); Mon, 20 Sep 2021 14:03:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D325F6323F; Mon, 20 Sep 2021 17:16:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158215; bh=jFcCMolORMRzw5EQjau9Hnqk/Q1zcbFyS3Q36idEqCY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zwvAWI6f8qk3r8rnZ+Ia+2uHcWDjIB1Fv/rKb95Uu2P/Cp2VV5p4YST0cEFd+nZ1P BM/p/SJoWX7B89ubfP7h5hI/5g291d8H/9G7iMOaC63llp0l91WICb+9lIAGuScFW6 bfte9WbUzvsmjW6Xq5fGuohCU8Mok9HU0eh9ej5w= 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.4 020/260] power: supply: max17042: handle fails of reading status register Date: Mon, 20 Sep 2021 18:40:38 +0200 Message-Id: <20210920163931.806223908@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163931.123590023@linuxfoundation.org> References: <20210920163931.123590023@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 @@ -842,8 +842,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");