aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/ice/ice_controlq.c
diff options
context:
space:
mode:
authorPreethi Banala <preethi.banala@intel.com>2018-08-09 09:28:55 -0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2018-08-23 12:51:44 -0400
commitb29bc220e2c7bd494a4605defcd93b18d5a8cf86 (patch)
tree5de1d2dc249a68935f6688a1c00970d1139f98cd /drivers/net/ethernet/intel/ice/ice_controlq.c
parentf8ba7db850350319348b6d3c276f8ba19bc098ef (diff)
ice: Clean control queues only when they are initialized
Clean control queues only when they are initialized. One of the ways to validate if the basic initialization is done is by checking value of cq->sq.head and cq->rq.head variables that specify the register address. This patch adds a check to avoid NULL pointer dereference crash when tried to shutdown uninitialized control queue. Signed-off-by: Preethi Banala <preethi.banala@intel.com> Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com> Tested-by: Tony Brelinski <tonyx.brelinski@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/ice/ice_controlq.c')
-rw-r--r--drivers/net/ethernet/intel/ice/ice_controlq.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/drivers/net/ethernet/intel/ice/ice_controlq.c b/drivers/net/ethernet/intel/ice/ice_controlq.c
index 7c511f144ed6..c064416080e7 100644
--- a/drivers/net/ethernet/intel/ice/ice_controlq.c
+++ b/drivers/net/ethernet/intel/ice/ice_controlq.c
@@ -597,10 +597,14 @@ static enum ice_status ice_init_check_adminq(struct ice_hw *hw)
597 return 0; 597 return 0;
598 598
599init_ctrlq_free_rq: 599init_ctrlq_free_rq:
600 ice_shutdown_rq(hw, cq); 600 if (cq->rq.head) {
601 ice_shutdown_sq(hw, cq); 601 ice_shutdown_rq(hw, cq);
602 mutex_destroy(&cq->sq_lock); 602 mutex_destroy(&cq->rq_lock);
603 mutex_destroy(&cq->rq_lock); 603 }
604 if (cq->sq.head) {
605 ice_shutdown_sq(hw, cq);
606 mutex_destroy(&cq->sq_lock);
607 }
604 return status; 608 return status;
605} 609}
606 610
@@ -706,10 +710,14 @@ static void ice_shutdown_ctrlq(struct ice_hw *hw, enum ice_ctl_q q_type)
706 return; 710 return;
707 } 711 }
708 712
709 ice_shutdown_sq(hw, cq); 713 if (cq->sq.head) {
710 ice_shutdown_rq(hw, cq); 714 ice_shutdown_sq(hw, cq);
711 mutex_destroy(&cq->sq_lock); 715 mutex_destroy(&cq->sq_lock);
712 mutex_destroy(&cq->rq_lock); 716 }
717 if (cq->rq.head) {
718 ice_shutdown_rq(hw, cq);
719 mutex_destroy(&cq->rq_lock);
720 }
713} 721}
714 722
715/** 723/**