Skip to content

Commit

Permalink
octeontx2-af: Check capability flag while freeing ipolicer memory
Browse files Browse the repository at this point in the history
[ Upstream commit 07cccff ]

Bandwidth profiles (ipolicer structure)is implemented only on CN10K
platform. But current code try to free the ipolicer memory without
checking the capibility flag leading to driver crash on OCTEONTX2
platform. This patch fixes the issue by add capability flag check.

Fixes: e8e095b ("octeontx2-af: cn10k: Bandwidth profiles config support")
Signed-off-by: Geetha sowjanya <gakula@marvell.com>
Signed-off-by: Sunil Goutham <sgoutham@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Geetha sowjanya authored and gregkh committed Sep 15, 2021
1 parent 5e0f8ea commit edb20aa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
Expand Up @@ -25,7 +25,7 @@ static int nix_update_mce_rule(struct rvu *rvu, u16 pcifunc,
int type, bool add);
static int nix_setup_ipolicers(struct rvu *rvu,
struct nix_hw *nix_hw, int blkaddr);
static void nix_ipolicer_freemem(struct nix_hw *nix_hw);
static void nix_ipolicer_freemem(struct rvu *rvu, struct nix_hw *nix_hw);
static int nix_verify_bandprof(struct nix_cn10k_aq_enq_req *req,
struct nix_hw *nix_hw, u16 pcifunc);
static int nix_free_all_bandprof(struct rvu *rvu, u16 pcifunc);
Expand Down Expand Up @@ -3849,7 +3849,7 @@ static void rvu_nix_block_freemem(struct rvu *rvu, int blkaddr,
kfree(txsch->schq.bmap);
}

nix_ipolicer_freemem(nix_hw);
nix_ipolicer_freemem(rvu, nix_hw);

vlan = &nix_hw->txvlan;
kfree(vlan->rsrc.bmap);
Expand Down Expand Up @@ -4225,11 +4225,14 @@ static int nix_setup_ipolicers(struct rvu *rvu,
return 0;
}

static void nix_ipolicer_freemem(struct nix_hw *nix_hw)
static void nix_ipolicer_freemem(struct rvu *rvu, struct nix_hw *nix_hw)
{
struct nix_ipolicer *ipolicer;
int layer;

if (!rvu->hw->cap.ipolicer)
return;

for (layer = 0; layer < BAND_PROF_NUM_LAYERS; layer++) {
ipolicer = &nix_hw->ipolicer[layer];

Expand Down

0 comments on commit edb20aa

Please sign in to comment.