Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2319063pxb; Mon, 20 Sep 2021 18:41:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnKiwZRlwmdBD24sx8ivCGEERAfgfQODxSjQa88x9RPgHl+10DG5zrZ4WY4dXZJcvuXxUN X-Received: by 2002:a05:6e02:13d4:: with SMTP id v20mr19719796ilj.247.1632188511932; Mon, 20 Sep 2021 18:41:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632188511; cv=none; d=google.com; s=arc-20160816; b=xUylispxa4vvCM8cCMwz8KpCsOmC6fPz7hSA/s+PHg2pR36MZnx13uJK+5WrYsdBrz 6Z3bOqLtREYnMNCIBMM31ET+9Nb1CWrcY6eQIzF0S8rzqs9u96sePsnLd0wniTyVhYzG ziMTu8lV9Z+cCaVxSzpqfOuLa8l6dMJJ4JfTBOFS+DylQ8VoQDdOrWoIWGpIMgABihgp qfWQZMPrylSi8mIMyRnTXMaRi7vHa+gj3sbnPf1ShRWsWcYcOwXn5W7WHalVIjW9wo4u YDWMz6U+Gy70q8QwlA6SCHMu4QbRWf3nesh2H4ILQtpcxOvANox+ZfBrR7WsfsEPPKTA XP2g== 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=pFbqQpxIJ1EIN7LwChQ+6z/s1H1rgq+qTl4ZHxbFR9w=; b=muu4uXbVqetqZ6jDRrD/mN+RRZ3wO6d1F9cQ7OCBowyaMSRQ+Y39gPxdYzoWtLyu0I 3dWnYwNy8YupvKAgyiwRowxI2i8wj2jCjcI50kFYIUKN5vC1b/Z8oI5Lg5sJ1A5Lg55v EiqfbsohIcsMdIwjCvkVxGNlvQ6DEJe5l14TNIUQ3B9dx2X4pB52HqT7kRTRNzX0Accg cTzlhgjQyXomQTgzCDG8DJtE8Yejln4QInFCEpzCmEQHDojYa9wz/PFr17qaMJtHbmjw VrICetCb9gBeI9xqEBtd6iWetZlEQrluRtvFLbrKvtOSpA9GA34yc2nmCwoetL7W/6Ay 62SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KSvWr1Z7; 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 f22si15778645jam.69.2021.09.20.18.41.40; Mon, 20 Sep 2021 18:41:51 -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=KSvWr1Z7; 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 S244019AbhITQux (ORCPT + 99 others); Mon, 20 Sep 2021 12:50:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:36476 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229672AbhITQtV (ORCPT ); Mon, 20 Sep 2021 12:49:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8A7AE61283; Mon, 20 Sep 2021 16:47:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632156474; bh=r1akpp0OlgBWPvRWUx9JtgJT8PLpL2XcHjM93vivU/0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KSvWr1Z7Y6zquQeifPjfF0cVHGKw7z3QTYoxnWqshGpGQxFeDwUL4sg5MWYdxjhKS nbx3VC5uml3w/EOhriPoi0UJtJi4KAZN1NHiVKXrIIT9SB1VC4LuPMv1vuyPr37MCA LrG6+nA8I05IS3e/7ABI1iNaNgO1Yu42xphDNLs0= 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.4 075/133] power: supply: max17042: handle fails of reading status register Date: Mon, 20 Sep 2021 18:42:33 +0200 Message-Id: <20210920163915.101183496@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163912.603434365@linuxfoundation.org> References: <20210920163912.603434365@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/max17042_battery.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/drivers/power/max17042_battery.c +++ b/drivers/power/max17042_battery.c @@ -760,8 +760,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");