From mboxrd@z Thu Jan 1 00:00:00 1970 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 DBE3CC43217 for ; Tue, 30 Nov 2021 15:07:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244452AbhK3PKV (ORCPT ); Tue, 30 Nov 2021 10:10:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244561AbhK3PCc (ORCPT ); Tue, 30 Nov 2021 10:02:32 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D6E9C0619FF; Tue, 30 Nov 2021 06:53:39 -0800 (PST) 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 sin.source.kernel.org (Postfix) with ESMTPS id AA66FCE1A81; Tue, 30 Nov 2021 14:53:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55A7FC53FD0; Tue, 30 Nov 2021 14:53:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638284017; bh=r2+hGVkNf5ayMWDym0CWmxwQAfcI0oZSKo0wah+zbyk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lh16bvySDfUKvIf1tUWloILQD2uA4u5NUBc7P/jQ0IA0X2U3kpJ4Xxo3Uo2flig8M 64eAxkEJDvW1xyRyjD6Is29Cjye/ZmalEduLEhDzZR3BWFwXEnxXh9JvmOeuK63bIj 9G7z0JT+1iZRjXGwLPkV46fidjQnzXWsXzWSUIjTa69o1OfT4mCnFM5/37mWjEO6Cy NBY08Mdjgep0EtZFvbnO42rUBJ/HpJjhhkc0AW8mfBMVaTJFasYChvablxd58j9e9Z r2gD8veBW9c+noIT+lyPxYbokCTtaLzMwJrPps52i1xDpniB1Y1V++0GXOEQA0hBHY t8DiZLoW04Wow== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: zhangyue , Jakub Kicinski , Sasha Levin , aelior@marvell.com, manishc@marvell.com, davem@davemloft.net, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 12/14] net: qed: fix the array may be out of bound Date: Tue, 30 Nov 2021 09:53:13 -0500 Message-Id: <20211130145317.946676-12-sashal@kernel.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211130145317.946676-1-sashal@kernel.org> References: <20211130145317.946676-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: zhangyue [ Upstream commit 0435a4d08032c8fba2966cebdac870e22238cacc ] If the variable 'p_bit->flags' is always 0, the loop condition is always 0. The variable 'j' may be greater than or equal to 32. At this time, the array 'p_aeu->bits[32]' may be out of bound. Signed-off-by: zhangyue Link: https://lore.kernel.org/r/20211125113610.273841-1-zhangyue1@kylinos.cn Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/qlogic/qed/qed_int.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qed/qed_int.c b/drivers/net/ethernet/qlogic/qed/qed_int.c index f8d1d02a3cd4a..289101ce0e409 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_int.c +++ b/drivers/net/ethernet/qlogic/qed/qed_int.c @@ -865,7 +865,7 @@ static int qed_int_deassertion(struct qed_hwfn *p_hwfn, if (!parities) continue; - for (j = 0, bit_idx = 0; bit_idx < 32; j++) { + for (j = 0, bit_idx = 0; bit_idx < 32 && j < 32; j++) { struct aeu_invert_reg_bit *p_bit = &p_aeu->bits[j]; if (qed_int_is_parity_flag(p_hwfn, p_bit) && @@ -903,7 +903,7 @@ static int qed_int_deassertion(struct qed_hwfn *p_hwfn, * to current group, making them responsible for the * previous assertion. */ - for (j = 0, bit_idx = 0; bit_idx < 32; j++) { + for (j = 0, bit_idx = 0; bit_idx < 32 && j < 32; j++) { long unsigned int bitmask; u8 bit, bit_len; @@ -1201,7 +1201,7 @@ static void qed_int_sb_attn_init(struct qed_hwfn *p_hwfn, memset(sb_info->parity_mask, 0, sizeof(u32) * NUM_ATTN_REGS); for (i = 0; i < NUM_ATTN_REGS; i++) { /* j is array index, k is bit index */ - for (j = 0, k = 0; k < 32; j++) { + for (j = 0, k = 0; k < 32 && j < 32; j++) { struct aeu_invert_reg_bit *p_aeu; p_aeu = &aeu_descs[i].bits[j]; -- 2.33.0