Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754979AbYHLNsK (ORCPT ); Tue, 12 Aug 2008 09:48:10 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754435AbYHLNqr (ORCPT ); Tue, 12 Aug 2008 09:46:47 -0400 Received: from mtagate5.uk.ibm.com ([195.212.29.138]:26505 "EHLO mtagate5.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754412AbYHLNqq (ORCPT ); Tue, 12 Aug 2008 09:46:46 -0400 From: Alexander Schmidt To: Roland Dreier , "of-ewg" , "of-general" , lkml , "linuxppc-dev" Subject: [PATCH 4/5 try2] ib/ehca: check idr_find() return value Date: Tue, 12 Aug 2008 15:46:27 +0200 User-Agent: KMail/1.9.9 Cc: Stefan Roscher , "Hoang-Nam Nguyen" , Joachim Fenkes , Christoph Raisch MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200808121546.27705.alexs@linux.vnet.ibm.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1149 Lines: 29 The idr_find() function may fail when trying to get the QP that is associated with a CQE, e.g. when a QP has been destroyed between the generation of a CQE and the poll request for it. In consequence, the return value of idr_find() must be checked and the CQE must be discarded when the QP cannot be found. Signed-off-by: Alexander Schmidt --- drivers/infiniband/hw/ehca/ehca_reqs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- infiniband.git.orig/drivers/infiniband/hw/ehca/ehca_reqs.c +++ infiniband.git/drivers/infiniband/hw/ehca/ehca_reqs.c @@ -680,8 +680,10 @@ repoll: read_lock(&ehca_qp_idr_lock); my_qp = idr_find(&ehca_qp_idr, cqe->qp_token); - wc->qp = &my_qp->ib_qp; read_unlock(&ehca_qp_idr_lock); + if (!my_qp) + goto repoll; + wc->qp = &my_qp->ib_qp; wc->byte_len = cqe->nr_bytes_transferred; wc->pkey_index = cqe->pkey_index; -- 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/