Received: by 2002:a05:6520:4d:b0:139:a872:a4c9 with SMTP id i13csp2563697lkm; Mon, 20 Sep 2021 18:49:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGfBTf6p0Icfu9VSe6tOIid8aR6XU1Eyu8EO1FAq4zOFB6HQeEeAMAy1jrJeh+YvsYLI0x X-Received: by 2002:a05:6e02:1307:: with SMTP id g7mr19573471ilr.141.1632188964277; Mon, 20 Sep 2021 18:49:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632188964; cv=none; d=google.com; s=arc-20160816; b=XK61vw7/G1EcZKwYVHBHhbQlZF3eMXIM7CXymLuE99lrCcRpynTrG7ffFjONgfskQr QzWXtNXIV8VQh+CUcc8jWjiZpw8EkLmysSxiSddFJgVr2PD3Eno/qxRrIPMGI1FKhpbY lcD96xyLA9jtal6MHaJmB40up/E2wwMl49Q/LN2Q3cKhT2bE/9eXsYaJ2wPTAb7xjeLv 22o57UrVSGGDWGRJodazgHyDYPIjLTGHlSiFP4Bi76lrGllLLLZ8kv6VxKrLNMt+penE u+vCoYrYNo0dZD2zxoCh8eZ7elLlAd7cvtgTN4ioWmV5gMGr0Flj3+4lngKmjObbyA7H chdw== 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=jV2IByLW2b3dyXJBtsi6YNhYJrq+ElAWAUbgtH83XaQ=; b=W/4vD78DA0oZWero4r0cnDrOQhO0ulGwkcAmlPqMgWbhIXHU7TeLO2IhB8s2vrQPUU Qh26Ip+mVSRt6SYKg8NRr9lHu50GCGTCH+1RgXsbSxVB7yKZlEK1jWgGGC0j2vj7R+KK cBWp81Cv2PLgKdhrb0lnb2rALyg+5iKGoEPuxWUgpyrJ9IRUNf6SMgVYq9+Vr8S9MnzF y9Vvok/k2gzevrtCFeTENi04oOVW6EBzpeymt8DPk3YW3z5xf+VC4NGWMNoY2mq06TNb oNR4/QDooviIXLof4H7i/y4NphUIGi9xxbhAjNOl8uQeo4B/71S3zmYuSPtbnnpfsuKp DtkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0GTvKniG; 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 r6si9379183iob.3.2021.09.20.18.49.13; Mon, 20 Sep 2021 18:49:24 -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=0GTvKniG; 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 S1349571AbhITRw7 (ORCPT + 99 others); Mon, 20 Sep 2021 13:52:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:51348 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353796AbhITRrK (ORCPT ); Mon, 20 Sep 2021 13:47:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 06D9B61BA2; Mon, 20 Sep 2021 17:10:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632157846; bh=rrVp7Iewfcp/5F7sFERnaaZZGjTiu3GaDuurNOLr644=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0GTvKniGMPqZd5e+JxHQZ170xGj/OjJR0LUulbPet7yBlPO0Z5GQqB+2VTJyUUClQ leAziDLQ1X7hxZ2dhDdcb0KiS9XS6wIolQCMLY4h8HPRL4KBhJavPXtfFkTfomLBOa uxJkyh+78RxBpzxoVx0MrjT0h2omXTMo6twVo3Js= 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 4.19 145/293] power: supply: max17042: handle fails of reading status register Date: Mon, 20 Sep 2021 18:41:47 +0200 Message-Id: <20210920163938.243532700@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163933.258815435@linuxfoundation.org> References: <20210920163933.258815435@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 @@ -856,8 +856,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");