]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
octeontx2-af: Free BPID bitmap on setup failure
authorHaoxiang Li <haoxiang_li2024@163.com>
Tue, 23 Jun 2026 11:43:16 +0000 (19:43 +0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 25 Jun 2026 15:47:59 +0000 (08:47 -0700)
nix_setup_bpids() allocates bp->bpids with rvu_alloc_bitmap(), which uses
a plain kcalloc(). If any of the following devm_kcalloc() allocations for
the BPID mapping arrays fails, the function returns without freeing the
bitmap. Free the BPID bitmap before returning from those error paths.

Fixes: d6212d2e41a0 ("octeontx2-af: Create BPIDs free pool")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20260623114316.2182271-1-haoxiang_li2024@163.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c

index d8989395e875dacd33cef0037ba063b78a8417a1..0297c7ab0614eacb17aabaedf1946ef1e3ff4f50 100644 (file)
@@ -528,19 +528,24 @@ static int nix_setup_bpids(struct rvu *rvu, struct nix_hw *hw, int blkaddr)
        bp->fn_map = devm_kcalloc(rvu->dev, bp->bpids.max,
                                  sizeof(u16), GFP_KERNEL);
        if (!bp->fn_map)
-               return -ENOMEM;
+               goto free_bpids;
 
        bp->intf_map = devm_kcalloc(rvu->dev, bp->bpids.max,
                                    sizeof(u8), GFP_KERNEL);
        if (!bp->intf_map)
-               return -ENOMEM;
+               goto free_bpids;
 
        bp->ref_cnt = devm_kcalloc(rvu->dev, bp->bpids.max,
                                   sizeof(u8), GFP_KERNEL);
        if (!bp->ref_cnt)
-               return -ENOMEM;
+               goto free_bpids;
 
        return 0;
+
+free_bpids:
+       rvu_free_bitmap(&bp->bpids);
+       bp->bpids.bmap = NULL;
+       return -ENOMEM;
 }
 
 void rvu_nix_flr_free_bpids(struct rvu *rvu, u16 pcifunc)