[11/17] net/bnxt: check device is started before flow creation

Message ID 20190903021901.25895-12-ajit.khaparde@broadcom.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers
Series bnxt patchset to improve rte flow support |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply issues

Commit Message

Ajit Khaparde Sept. 3, 2019, 2:18 a.m. UTC
  Check device is started before flow creation.
Since the vnic data structures aren't created until device start,
the driver dereferences NULL vnic if flow creation is attempted before
device is started,

Reported-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
---
 drivers/net/bnxt/bnxt_flow.c | 9 +++++++++
 1 file changed, 9 insertions(+)
  

Patch

diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c
index 578081890..71a5266ce 100644
--- a/drivers/net/bnxt/bnxt_flow.c
+++ b/drivers/net/bnxt/bnxt_flow.c
@@ -1466,6 +1466,15 @@  bnxt_flow_create(struct rte_eth_dev *dev,
 	int ret = 0;
 	uint32_t tun_type;
 
+	if (!dev->data->dev_started) {
+		rte_flow_error_set(error,
+				   EINVAL,
+				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+				   NULL,
+				   "Device must be started");
+		return NULL;
+	}
+
 	flow = rte_zmalloc("bnxt_flow", sizeof(struct rte_flow), 0);
 	if (!flow) {
 		rte_flow_error_set(error, ENOMEM,