octeontx2-pf: Add check for devm_kcalloc
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Tue, 22 Nov 2022 05:54:49 +0000 (13:54 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 Dec 2022 16:41:07 +0000 (17:41 +0100)
[ Upstream commit cd07eadd5147ffdae11b6fd28b77a3872f2a2484 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c

index 603361c94786aaa74be164ec98fe07b714712b8c..09892703cfd46add621ec80510dd63c497dfc1ea 100644 (file)
@@ -4832,6 +4832,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 */