Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933882AbYCDWpP (ORCPT ); Tue, 4 Mar 2008 17:45:15 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754284AbYCDWox (ORCPT ); Tue, 4 Mar 2008 17:44:53 -0500 Received: from 209-198-142-2-host.prismnet.net ([209.198.142.2]:57851 "EHLO smtp.opengridcomputing.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754081AbYCDWow (ORCPT ); Tue, 4 Mar 2008 17:44:52 -0500 From: Steve Wise Subject: [PATCH 2.6.25] RDMA/IWCM: don't access the cm_id after dereferencing it. Date: Tue, 04 Mar 2008 16:44:52 -0600 To: rdreier@cisco.com, sean.hefty@intel.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, general@lists.openfabrics.org Message-Id: <20080304224451.8548.33855.stgit@dell3.ogc.int> Content-Type: text/plain; charset=utf-8; format=fixed Content-Transfer-Encoding: 8bit User-Agent: StGIT/0.10 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1562 Lines: 43 RDMA/IWCM: don't access the cm_id after dereferencing it. cm_work_handler() can access cm_id_priv after it was potentially freed by iwch_deref_id(). The fix is to note whether IWCM_F_CALLBACK_DESTROY is set before dereferencing. Then if it was set, free the cm_id on this thread. Signed-off-by: Steve Wise --- drivers/infiniband/core/iwcm.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c index 223b1aa..81c9195 100644 --- a/drivers/infiniband/core/iwcm.c +++ b/drivers/infiniband/core/iwcm.c @@ -839,6 +839,7 @@ static void cm_work_handler(struct work_struct *_work) unsigned long flags; int empty; int ret = 0; + int destroy_id; spin_lock_irqsave(&cm_id_priv->lock, flags); empty = list_empty(&cm_id_priv->work_list); @@ -857,9 +858,9 @@ static void cm_work_handler(struct work_struct *_work) destroy_cm_id(&cm_id_priv->id); } BUG_ON(atomic_read(&cm_id_priv->refcount)==0); + destroy_id = test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags); if (iwcm_deref_id(cm_id_priv)) { - if (test_bit(IWCM_F_CALLBACK_DESTROY, - &cm_id_priv->flags)) { + if (destroy_id) { BUG_ON(!list_empty(&cm_id_priv->work_list)); free_cm_id(cm_id_priv); } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/