From patchwork Tue Nov 15 09:51:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 9429249 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E5FC760484 for ; Tue, 15 Nov 2016 09:51:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7B0E28AC5 for ; Tue, 15 Nov 2016 09:51:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA4BC28ACE; Tue, 15 Nov 2016 09:51:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F97928AC5 for ; Tue, 15 Nov 2016 09:51:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941347AbcKOJvY (ORCPT ); Tue, 15 Nov 2016 04:51:24 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:50209 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935704AbcKOJvW (ORCPT ); Tue, 15 Nov 2016 04:51:22 -0500 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id uAF9pGZU017848 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Nov 2016 09:51:16 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id uAF9pFhK014434 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 15 Nov 2016 09:51:16 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id uAF9pD0P017917; Tue, 15 Nov 2016 09:51:14 GMT Received: from mwanda (/154.122.119.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 15 Nov 2016 01:51:11 -0800 Date: Tue, 15 Nov 2016 12:51:00 +0300 From: Dan Carpenter To: Doug Ledford , Ram Amrani Cc: Sean Hefty , Hal Rosenstock , Rajesh Borundia , linux-rdma@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch] qedr: Unlock on error in qedr_post_send() Message-ID: <20161115095059.GB15424@mwanda> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.6.0 (2016-04-01) X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If "wr" is NULL then we return without unlocking. I added an unlock label and changed the direct returns to gotos. Fixes: afa0e13be754 ("qedr: Add support for data path") Signed-off-by: Dan Carpenter --- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c index a615142..01d05b0 100644 --- a/drivers/infiniband/hw/qedr/verbs.c +++ b/drivers/infiniband/hw/qedr/verbs.c @@ -2973,17 +2973,18 @@ int qedr_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, if ((qp->state == QED_ROCE_QP_STATE_RESET) || (qp->state == QED_ROCE_QP_STATE_ERR)) { - spin_unlock_irqrestore(&qp->q_lock, flags); *bad_wr = wr; DP_DEBUG(dev, QEDR_MSG_CQ, "QP in wrong state! QP icid=0x%x state %d\n", qp->icid, qp->state); - return -EINVAL; + rc = -EINVAL; + goto unlock; } if (!wr) { DP_ERR(dev, "Got an empty post send.\n"); - return -EINVAL; + rc = -EINVAL; + goto unlock; } while (wr) { @@ -3012,6 +3013,7 @@ int qedr_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, /* Make sure write sticks */ mmiowb(); +unlock: spin_unlock_irqrestore(&qp->q_lock, flags); return rc;