From: Ajit Khaparde <ajit.khaparde@broadcom.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com
Subject: [dpdk-dev] [PATCH 1/4] net/bnxt: fix cleanup if a filter allocation fails
Date: Tue, 10 Oct 2017 09:23:00 -0500 [thread overview]
Message-ID: <20171010142303.17433-2-ajit.khaparde@broadcom.com> (raw)
In-Reply-To: <20171010142303.17433-1-ajit.khaparde@broadcom.com>
We are not checking if a filter allocation succeeded.
And we end up accessing a null pointer after that.
Also invalidate the fw_l2_filter_id to prevent unnecessary
HW access and hence HWRM command failures during exit.
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/bnxt_filter.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c
index 9f171fd99..4c1db559d 100644
--- a/drivers/net/bnxt/bnxt_filter.c
+++ b/drivers/net/bnxt/bnxt_filter.c
@@ -828,12 +828,20 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
}
filter->dst_id = vnic->fw_vnic_id;
filter1 = bnxt_get_l2_filter(bp, filter, vnic);
+ if (filter1 == NULL) {
+ rc = -ENOSPC;
+ goto ret;
+ }
filter->fw_l2_filter_id = filter1->fw_l2_filter_id;
RTE_LOG(DEBUG, PMD, "VNIC found\n");
break;
case RTE_FLOW_ACTION_TYPE_DROP:
vnic0 = STAILQ_FIRST(&bp->ff_pool[0]);
filter1 = bnxt_get_l2_filter(bp, filter, vnic0);
+ if (filter1 == NULL) {
+ rc = -ENOSPC;
+ goto ret;
+ }
filter->fw_l2_filter_id = filter1->fw_l2_filter_id;
if (filter->filter_type == HWRM_CFA_EM_FILTER)
filter->flags =
@@ -845,6 +853,10 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
case RTE_FLOW_ACTION_TYPE_COUNT:
vnic0 = STAILQ_FIRST(&bp->ff_pool[0]);
filter1 = bnxt_get_l2_filter(bp, filter, vnic0);
+ if (filter1 == NULL) {
+ rc = -ENOSPC;
+ goto ret;
+ }
filter->fw_l2_filter_id = filter1->fw_l2_filter_id;
filter->flags = HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_FLAGS_METER;
break;
@@ -892,6 +904,7 @@ bnxt_flow_validate(struct rte_eth_dev *dev,
ret = bnxt_validate_and_parse_flow(dev, pattern, actions, attr,
error, filter);
/* No need to hold on to this filter if we are just validating flow */
+ filter->fw_l2_filter_id = -1;
bnxt_free_filter(bp, filter);
return ret;
@@ -961,6 +974,7 @@ bnxt_flow_create(struct rte_eth_dev *dev,
return flow;
}
free_filter:
+ filter->fw_l2_filter_id = -1;
bnxt_free_filter(bp, filter);
free_flow:
RTE_LOG(ERR, PMD, "Failed to create flow.\n");
--
2.13.5 (Apple Git-94)
next prev parent reply other threads:[~2017-10-10 14:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-10 14:22 [dpdk-dev] [PATCH 0/4] patches for bnxt Ajit Khaparde
2017-10-10 14:23 ` Ajit Khaparde [this message]
2017-10-10 14:23 ` [dpdk-dev] [PATCH 2/4] net/bnxt: prevent programming a duplicate flow Ajit Khaparde
2017-10-10 14:23 ` [dpdk-dev] [PATCH 3/4] net/bnxt: include fdir support Ajit Khaparde
2017-10-10 14:23 ` [dpdk-dev] [PATCH 4/4] net/bnxt: fix the association of a MACVLAN per VNIC Ajit Khaparde
2017-10-11 2:08 ` [dpdk-dev] [PATCH 0/4] patches for bnxt Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171010142303.17433-2-ajit.khaparde@broadcom.com \
--to=ajit.khaparde@broadcom.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).