Re: [PATCH net v6] bnxt_en: validate firmware backing store types

From: Michael Chan

Date: Sat Mar 28 2026 - 14:16:03 EST


On Fri, Mar 27, 2026 at 11:08 PM Pengpeng Hou <pengpeng@xxxxxxxxxxx> wrote:
>
> 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.

Please change the title of the commit since you are not validating the
type in the FW response anymore.

> @@ -8700,22 +8701,24 @@ static int bnxt_hwrm_func_backing_store_qcaps_v2(struct bnxt *bp)
> if (rc)
> goto ctx_done;
> flags = le32_to_cpu(resp->flags);
> - type = le16_to_cpu(resp->next_valid_type);
> + next_type = le16_to_cpu(resp->next_valid_type);
> if (!(flags & BNXT_CTX_MEM_TYPE_VALID)) {
> bnxt_free_one_ctx_mem(bp, ctxm, true);
> + type = next_type;

You can just update type = next_type in the for loop statement instead
of updating it in 3 different places:

for (type = 0; type < BNXT_CTX_V2_MAX; type = next_type)

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature