Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp178598pxb; Mon, 13 Sep 2021 16:21:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOc4kOf8fCB9mZk0Zmiv1WB1tnIBgZAOZoYX9g0gtYFW/YQntH+sPyVudFEyaJZ76mzixf X-Received: by 2002:a17:906:410c:: with SMTP id j12mr15409932ejk.161.1631575262975; Mon, 13 Sep 2021 16:21:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631575262; cv=none; d=google.com; s=arc-20160816; b=w/ko056bWFTIp5enbsHmW6Wr4tk3mqVMUDyNhCugK/8iCKRH0+bYhGIdNHaTb9Ga71 iNPX3TjqFlcghlsHljfKZcmVqEeZPypxp1OUoAnc3M/Pvl7W6fcPoG1eWQOJcfRkpsIP ph7+KDILmqXmkrT9KLMuOBMIg52f/Yi/h021VgTUUrb1dUml+vOOr2duPhAzhEnVIWGD 3wdYHvvZDBVwk6AkvVhVtxcT+tkOWl/ush/P1tBIYlhUTWYZsc9woEVUjVDI0hle8uU7 Xvap4eIC4/fk2JDihTT7Rgs9lunmMqpSNMtnlZPs2s+Ce9LoWMZNADQ8EmlUVmPBRNoe WSkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vXT5b+l726GZa+uiM/zuoChZqu3JUlHj284aO/Lc7gs=; b=j9FK87tc8vG3UYOb+01MXz/usgy1OzWJsTOzsNLZJibQVHyyO2Me8n4FzEQEOgzBLr LApsWnBVG5tCzAjZ5XuupimVgvIuEkEZGQC6fcyrjvgLN0Zer1NRW5hT6ZBXeeUpnny4 SZ4BDEskpRG3breJ1rkjwXWSPdck2etJaMTpQZgyBihD/iheaq0Zplhe4Qnu6qT3zq6L jpDkSYMW0qngkEysy+8xig5I5zRs8JQlzKk0flN2UGrI3YwZOiBbk7AAOXxYQb3G3+ix UGjskQNUwtqOTef8bDwfiT7FrhpPp+hSCYf4UGg8NHlPiLsHIeSlHUuuOHFGlscBEh39 9OSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WWOx+lVV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c17si8352551ede.270.2021.09.13.16.20.39; Mon, 13 Sep 2021 16:21:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WWOx+lVV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344742AbhIMOra (ORCPT + 99 others); Mon, 13 Sep 2021 10:47:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:60204 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345135AbhIMOlq (ORCPT ); Mon, 13 Sep 2021 10:41:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A6FB06124A; Mon, 13 Sep 2021 13:56:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631541381; bh=3HgTSiSenMZLALV6ean9E0Invt9sKdJ7P5fruDSHcSA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WWOx+lVVVXpnLzxJi6CdA3PX0klx66SX3uT/UDKK5xK7TBV849bvXISsdC2L5UvG8 D7BNQt+hfW8p4Gr2ukezVQo2tANSrGdzIHntrv5qPhaMmtuGeF8KsGtyG/1AYsDunQ +5CzmR53vvj2WOLeb8LTWb6qjZKzvn3yWM7xeUlU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geetha sowjanya , Sunil Goutham , "David S. Miller" , Sasha Levin Subject: [PATCH 5.14 242/334] octeontx2-af: Check capability flag while freeing ipolicer memory Date: Mon, 13 Sep 2021 15:14:56 +0200 Message-Id: <20210913131121.583008323@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131113.390368911@linuxfoundation.org> References: <20210913131113.390368911@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Geetha sowjanya [ Upstream commit 07cccffdbdd37820ba13c645af8e74a78a266557 ] 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: e8e095b3b3700 ("octeontx2-af: cn10k: Bandwidth profiles config support") Signed-off-by: Geetha sowjanya Signed-off-by: Sunil Goutham Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c index 4bfbbdf38770..c32195073e8a 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c @@ -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); @@ -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); @@ -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]; -- 2.30.2