]> git.itanic.dy.fi Git - linux-stable/commitdiff
octeontx2-pf: Add check for devm_kcalloc
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Tue, 22 Nov 2022 05:54:49 +0000 (13:54 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 24 Nov 2022 07:34:45 +0000 (08:34 +0100)
As the devm_kcalloc may return NULL pointer,
it should be better to add check for the return
value, as same as the others.

Fixes: e8e095b3b370 ("octeontx2-af: cn10k: Bandwidth profiles config support")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Link: https://lore.kernel.org/r/20221122055449.31247-1-jiasheng@iscas.ac.cn
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c

index 7646bb2ec89b9e5bfa6e658506cf9796e5b59c34..a62c1b3220120c299c938ff638d93eba826e0adc 100644 (file)
@@ -4985,6 +4985,8 @@ static int nix_setup_ipolicers(struct rvu *rvu,
                ipolicer->ref_count = devm_kcalloc(rvu->dev,
                                                   ipolicer->band_prof.max,
                                                   sizeof(u16), GFP_KERNEL);
+               if (!ipolicer->ref_count)
+                       return -ENOMEM;
        }
 
        /* Set policer timeunit to 2us ie  (19 + 1) * 100 nsec = 2us */