[07/25] net/bnxt: add a null ptr check for the resource manager
diff mbox series

Message ID 20200911015603.88359-8-ajit.khaparde@broadcom.com
State Superseded
Delegated to: Ajit Khaparde
Headers show
Series
  • patchset for bnxt
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ajit Khaparde Sept. 11, 2020, 1:55 a.m. UTC
From: Shahaji Bhosle <sbhosle@broadcom.com>

Verify the resource manager exists prior to using

Signed-off-by: Shahaji Bhosle <sbhosle@broadcom.com>
Reviewed-by: Mike Baucom <michael.baucom@broadcom.com>
---
 drivers/net/bnxt/tf_core/tf_rm.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Patch
diff mbox series

diff --git a/drivers/net/bnxt/tf_core/tf_rm.c b/drivers/net/bnxt/tf_core/tf_rm.c
index 9aec954db..66a33583b 100644
--- a/drivers/net/bnxt/tf_core/tf_rm.c
+++ b/drivers/net/bnxt/tf_core/tf_rm.c
@@ -706,6 +706,8 @@  tf_rm_allocate(struct tf_rm_allocate_parms *parms)
 	TF_CHECK_PARMS2(parms, parms->rm_db);
 
 	rm_db = (struct tf_rm_new_db *)parms->rm_db;
+	if (!rm_db->db)
+		return -EINVAL;
 	cfg_type = rm_db->db[parms->db_index].cfg_type;
 
 	/* Bail out if not controlled by RM */
@@ -772,6 +774,8 @@  tf_rm_free(struct tf_rm_free_parms *parms)
 	TF_CHECK_PARMS2(parms, parms->rm_db);
 
 	rm_db = (struct tf_rm_new_db *)parms->rm_db;
+	if (!rm_db->db)
+		return -EINVAL;
 	cfg_type = rm_db->db[parms->db_index].cfg_type;
 
 	/* Bail out if not controlled by RM */
@@ -817,6 +821,8 @@  tf_rm_is_allocated(struct tf_rm_is_allocated_parms *parms)
 	TF_CHECK_PARMS2(parms, parms->rm_db);
 
 	rm_db = (struct tf_rm_new_db *)parms->rm_db;
+	if (!rm_db->db)
+		return -EINVAL;
 	cfg_type = rm_db->db[parms->db_index].cfg_type;
 
 	/* Bail out if not controlled by RM */
@@ -860,6 +866,8 @@  tf_rm_get_info(struct tf_rm_get_alloc_info_parms *parms)
 	TF_CHECK_PARMS2(parms, parms->rm_db);
 
 	rm_db = (struct tf_rm_new_db *)parms->rm_db;
+	if (!rm_db->db)
+		return -EINVAL;
 	cfg_type = rm_db->db[parms->db_index].cfg_type;
 
 	/* Bail out if not controlled by HCAPI */
@@ -883,6 +891,8 @@  tf_rm_get_hcapi_type(struct tf_rm_get_hcapi_parms *parms)
 	TF_CHECK_PARMS2(parms, parms->rm_db);
 
 	rm_db = (struct tf_rm_new_db *)parms->rm_db;
+	if (!rm_db->db)
+		return -EINVAL;
 	cfg_type = rm_db->db[parms->db_index].cfg_type;
 
 	/* Bail out if not controlled by HCAPI */
@@ -905,6 +915,8 @@  tf_rm_get_inuse_count(struct tf_rm_get_inuse_count_parms *parms)
 	TF_CHECK_PARMS2(parms, parms->rm_db);
 
 	rm_db = (struct tf_rm_new_db *)parms->rm_db;
+	if (!rm_db->db)
+		return -EINVAL;
 	cfg_type = rm_db->db[parms->db_index].cfg_type;
 
 	/* Bail out if not controlled by RM */
@@ -937,6 +949,8 @@  tf_rm_check_indexes_in_range(struct tf_rm_check_indexes_in_range_parms *parms)
 	TF_CHECK_PARMS2(parms, parms->rm_db);
 
 	rm_db = (struct tf_rm_new_db *)parms->rm_db;
+	if (!rm_db->db)
+		return -EINVAL;
 	cfg_type = rm_db->db[parms->db_index].cfg_type;
 
 	/* Bail out if not controlled by RM */