From patchwork Tue Dec 6 09:17:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Arefev X-Patchwork-Id: 631481 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E956BC352A1 for ; Tue, 6 Dec 2022 09:19:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235010AbiLFJT2 (ORCPT ); Tue, 6 Dec 2022 04:19:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233558AbiLFJRl (ORCPT ); Tue, 6 Dec 2022 04:17:41 -0500 Received: from mx.swemel.ru (mx.swemel.ru [95.143.211.150]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94A741F9E2; Tue, 6 Dec 2022 01:17:27 -0800 (PST) From: Denis Arefev DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=swemel.ru; s=mail; t=1670318243; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=L6AmVYk+3czGQRwn6dfUAWPTlXwM30IpBMZAykr0mwg=; b=EXaZd0awXs7QnHyQ6CVLCrXaKkMPfUg3zglbCFyGPKonX14N3Jwrvp9bFdSN1npg0LCJdA SmItxkhCPnSp+ivyly5ikx48qQV5Rux61FthN/SkwTdTc/jMVu4cvce7oVtn3SBTuFScOh HgyQvzpCy8AmYe1dghreK65S4K6ucdc= To: Sebastian Reichel Cc: Chen-Yu Tsai , Hans de Goede , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, trufanov@swemel.ru, vfh@swemel.ru Subject: [PATCH] power: supply: Added check for negative values Date: Tue, 6 Dec 2022 12:17:23 +0300 Message-Id: <20221206091723.28656-1-arefev@swemel.ru> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Variable 'pirq', which may receive negative value in platform_get_irq(). Used as an index in a function regmap_irq_get_virq(). Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Denis Arefev --- drivers/power/supply/axp288_fuel_gauge.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/power/supply/axp288_fuel_gauge.c b/drivers/power/supply/axp288_fuel_gauge.c index 148eb8105803..36c7039c99c2 100644 --- a/drivers/power/supply/axp288_fuel_gauge.c +++ b/drivers/power/supply/axp288_fuel_gauge.c @@ -640,6 +640,8 @@ static void fuel_gauge_init_irq(struct axp288_fg_info *info) for (i = 0; i < AXP288_FG_INTR_NUM; i++) { pirq = platform_get_irq(info->pdev, i); + if (pirq < 0) + continue; info->irq[i] = regmap_irq_get_virq(info->regmap_irqc, pirq); if (info->irq[i] < 0) { dev_warn(&info->pdev->dev,