From owner-svn-src-head@freebsd.org Tue Jun 14 20:58:06 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7866CB72551; Tue, 14 Jun 2016 20:58:06 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3B13422D3; Tue, 14 Jun 2016 20:58:06 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5EKw5fC012794; Tue, 14 Jun 2016 20:58:05 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5EKw5ci012793; Tue, 14 Jun 2016 20:58:05 GMT (envelope-from np@FreeBSD.org) Message-Id: <201606142058.u5EKw5ci012793@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Tue, 14 Jun 2016 20:58:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r301896 - head/sys/ofed/drivers/infiniband/core X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jun 2016 20:58:06 -0000 Author: np Date: Tue Jun 14 20:58:05 2016 New Revision: 301896 URL: https://svnweb.freebsd.org/changeset/base/301896 Log: Fix bug in iwcm that caused a panic in iw_cm_wq when krping is run repeatedly in a tight loop. Approved by: re (gjb@) Obtained from: hselasky@ (part of larger changes in D5791) Modified: head/sys/ofed/drivers/infiniband/core/iwcm.c Modified: head/sys/ofed/drivers/infiniband/core/iwcm.c ============================================================================== --- head/sys/ofed/drivers/infiniband/core/iwcm.c Tue Jun 14 18:41:18 2016 (r301895) +++ head/sys/ofed/drivers/infiniband/core/iwcm.c Tue Jun 14 20:58:05 2016 (r301896) @@ -266,9 +266,16 @@ static void add_ref(struct iw_cm_id *cm_ static void rem_ref(struct iw_cm_id *cm_id) { struct iwcm_id_private *cm_id_priv; + int cb_destroy; + cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); - if (iwcm_deref_id(cm_id_priv) && - test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags)) { + + /* + * Test bit before deref in case the cm_id gets freed on another + * thread. + */ + cb_destroy = test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags); + if (iwcm_deref_id(cm_id_priv) && cb_destroy) { BUG_ON(!list_empty(&cm_id_priv->work_list)); free_cm_id(cm_id_priv); } @@ -1157,6 +1164,8 @@ static void cm_work_handler(struct work_ } return; } + if (empty) + return; spin_lock_irqsave(&cm_id_priv->lock, flags); } spin_unlock_irqrestore(&cm_id_priv->lock, flags);