From nobody Fri Oct 17 10:32:15 2025 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 7882FC4332F for ; Wed, 19 Oct 2022 10:06:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230266AbiJSKG3 (ORCPT ); Wed, 19 Oct 2022 06:06:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231200AbiJSKFy (ORCPT ); Wed, 19 Oct 2022 06:05:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFE29229; Wed, 19 Oct 2022 02:44:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5B957617EB; Wed, 19 Oct 2022 09:13:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F2E3C433B5; Wed, 19 Oct 2022 09:13:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170837; bh=PyVuP224LTfOgKeY7PGhWDcswJIc+RIZ/ujbhn1tRm4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VJ6uXsN0P5w7KkgvZN2wCYMpmIPGwPYvL/iKnjPgzGgvbqEXhYPB4jH4tBfmsx2E6 f8nE7DiNxjQ1byFgzCdr8/IHEN/5LbQVvy5r7cjf5pCzeG28fM9kn5dqbiyNcldXPv ZAMHwVjcXSH8D7h6RnIEAucV6ZNLotlvcS8qofaU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wei Yongjun , Michael Hennerich , Sebastian Reichel , Sasha Levin Subject: [PATCH 6.0 805/862] power: supply: adp5061: fix out-of-bounds read in adp5061_get_chg_type() Date: Wed, 19 Oct 2022 10:34:52 +0200 Message-Id: <20221019083325.471951056@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Wei Yongjun [ Upstream commit 9d47e01b9d807808224347935562f7043a358054 ] ADP5061_CHG_STATUS_1_CHG_STATUS is masked with 0x07, which means a length of 8, but adp5061_chg_type array size is 4, may end up reading 4 elements beyond the end of the adp5061_chg_type[] array. Signed-off-by: Wei Yongjun Acked-by: Michael Hennerich Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin --- drivers/power/supply/adp5061.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/power/supply/adp5061.c b/drivers/power/supply/adp5061.c index 003557043ab3..daee1161c305 100644 --- a/drivers/power/supply/adp5061.c +++ b/drivers/power/supply/adp5061.c @@ -427,11 +427,11 @@ static int adp5061_get_chg_type(struct adp5061_state = *st, if (ret < 0) return ret; =20 - chg_type =3D adp5061_chg_type[ADP5061_CHG_STATUS_1_CHG_STATUS(status1)]; - if (chg_type > ADP5061_CHG_FAST_CV) + chg_type =3D ADP5061_CHG_STATUS_1_CHG_STATUS(status1); + if (chg_type >=3D ARRAY_SIZE(adp5061_chg_type)) val->intval =3D POWER_SUPPLY_STATUS_UNKNOWN; else - val->intval =3D chg_type; + val->intval =3D adp5061_chg_type[chg_type]; =20 return ret; } --=20 2.35.1