From nobody Thu Apr 2 14:09:46 2026 Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFFF717B506; Sat, 28 Mar 2026 06:08:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.226.251.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774678129; cv=none; b=djj0WB6zLxf+DEg4I9xLbvIczlsWOdHvQoDHDe/5Ys7iMCtKpnD6qPRWpALKS3GYCva/PA+082PaQ3MKGlILWwk5AK5sKmGgRKEqXUAWkzWC+8pdVGmo7YEvDRFyMyauV47ZGB2GA/iiICmpNqCj5jG5VTxfufbGAm3KIELDsfQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774678129; c=relaxed/simple; bh=A95b8KlzZz2eDf55jdQfAaj0poHyTWSSRVpjOe4sXSE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=MOVJLC7UsOAU5gc064GcnqIi9Y+2sb7kLGikg6EBb2irti8M16/LF9D61pB10sbAMnlDcSYAGVsecXHgvSw0l1sBLAC4+fbaqJNT1BGN6QtHurzFahgQJI7EJ/jE6Y/s1VU1noQqyG6khL+4rL9a3SyrJgPW/MhMaoQ36Po0rIM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn; spf=pass smtp.mailfrom=iscas.ac.cn; arc=none smtp.client-ip=159.226.251.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iscas.ac.cn Received: from localhost.localdomain (unknown [111.196.245.197]) by APP-01 (Coremail) with SMTP id qwCowACXQm5YcMdpboNsCw--.8017S2; Sat, 28 Mar 2026 14:08:25 +0800 (CST) From: Pengpeng Hou To: michael.chan@broadcom.com Cc: pavan.chebbi@broadcom.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, pengpeng@iscas.ac.cn Subject: [PATCH net v6] bnxt_en: validate firmware backing store types Date: Sat, 28 Mar 2026 14:08:24 +0800 Message-ID: <20260328060824.8383-1-pengpeng@iscas.ac.cn> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qwCowACXQm5YcMdpboNsCw--.8017S2 X-Coremail-Antispam: 1UD129KBjvJXoWxXw4kCr13Zw43ur47Wr43trb_yoW5WF1xpF 45urWaqr18Jr13tay5KF48Xrn8Ww4Sg348JFy29w1FvF1ayF1jy34kCFy3tryDurWxurya qa1jywn5t390g3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9Y14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVCY1x0267AKxVWxJr 0_GcWle2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2 Y2ka0xkIwI1lc7CjxVAaw2AFwI0_Jw0_GFyl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x 0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2 zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF 4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWU CwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCT nIWIevJa73UjIFyTuYvjfUonmRUUUUU X-CM-SenderInfo: pshqw1xhqjqxpvfd2hldfou0/ Content-Type: text/plain; charset="utf-8" bnxt_hwrm_func_backing_store_qcaps_v2() stores resp->type from the firmware response in ctxm->type and later uses that value to index fixed backing-store metadata arrays such as ctx_arr[] and bnxt_bstore_to_trace[]. ctxm->type is fixed by the current backing-store query type and matches the array index of ctx->ctx_arr. Avoid depending on resp->type and assign ctxm->type from the current loop variable instead. Keep next_valid_type in a dedicated variable so loop control stays clear for non-valid or unchanged entries. Fixes: 6a4d0774f02d ("bnxt_en: Add support for new backing store query firm= ware API") Signed-off-by: Pengpeng Hou --- v6: - assign ctxm->type from the current query type - stop depending on resp->type Link: https://lore.kernel.org/r/20260327010235.42668-1-pengpeng@iscas.ac.cn drivers/net/ethernet/broadcom/bnxt/bnxt.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethern= et/broadcom/bnxt/bnxt.c index 0751c0e4581a..db8152c66d32 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -8692,6 +8692,7 @@ static int bnxt_hwrm_func_backing_store_qcaps_v2(stru= ct bnxt *bp) u8 init_val, init_off, i; u32 max_entries; u16 entry_size; + u16 next_type; __le32 *p; u32 flags; =20 @@ -8700,22 +8701,24 @@ static int bnxt_hwrm_func_backing_store_qcaps_v2(st= ruct bnxt *bp) if (rc) goto ctx_done; flags =3D le32_to_cpu(resp->flags); - type =3D le16_to_cpu(resp->next_valid_type); + next_type =3D le16_to_cpu(resp->next_valid_type); if (!(flags & BNXT_CTX_MEM_TYPE_VALID)) { bnxt_free_one_ctx_mem(bp, ctxm, true); + type =3D next_type; continue; } entry_size =3D le16_to_cpu(resp->entry_size); max_entries =3D le32_to_cpu(resp->max_num_entries); if (ctxm->mem_valid) { - if (!(flags & BNXT_CTX_MEM_PERSIST) || - ctxm->entry_size !=3D entry_size || - ctxm->max_entries !=3D max_entries) - bnxt_free_one_ctx_mem(bp, ctxm, true); - else + if ((flags & BNXT_CTX_MEM_PERSIST) && + ctxm->entry_size =3D=3D entry_size && + ctxm->max_entries =3D=3D max_entries) { + type =3D next_type; continue; + } + bnxt_free_one_ctx_mem(bp, ctxm, true); } - ctxm->type =3D le16_to_cpu(resp->type); + ctxm->type =3D type; ctxm->entry_size =3D entry_size; ctxm->flags =3D flags; ctxm->instance_bmap =3D le32_to_cpu(resp->instance_bit_map); @@ -8731,6 +8734,7 @@ static int bnxt_hwrm_func_backing_store_qcaps_v2(stru= ct bnxt *bp) for (i =3D 0, p =3D &resp->split_entry_0; i < ctxm->split_entry_cnt; i++, p++) ctxm->split[i] =3D le32_to_cpu(*p); + type =3D next_type; } rc =3D bnxt_alloc_all_ctx_pg_info(bp, BNXT_CTX_V2_MAX); =20 --=20 2.50.1 (Apple Git-155)