Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp693363pxb; Tue, 5 Apr 2022 19:03:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxomEX/+69gTLMZ0cp3OJW3ME0LEhgjnVODnM6aN8DsGhqyJYctqSov2aw2biCwtoGGTOEe X-Received: by 2002:a05:6a00:14d5:b0:4fb:2adf:dcdd with SMTP id w21-20020a056a0014d500b004fb2adfdcddmr6583202pfu.72.1649210593260; Tue, 05 Apr 2022 19:03:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649210593; cv=none; d=google.com; s=arc-20160816; b=GxxqpUHzt6k7kAoXikJ/mhhXmDjEAQoqxkL1BXlXmM80JrZhQGs5leyf5HKDvCl2ki vtqxxmw041F1MTTMy1u2EZJuoqMOSfJxL8pbPy4+nzkGG+oUAUD4TC92o2rcXcuQX/Lf 0E5kjJLjp+t34leqYI6AKqsMtQqGBhBEQBTta0KwLOyojSxk8uS03nSCmB2wlId4mFEt 6v+O5zwM2vQQAqfGzNtP2gnp1O1wrrE5hD+giUOlfqTZ4IlFNHD7gEYDzAPKbGB3cHRy 1SYoJusH4udiZsnCwZx0658JB+0IOxUBVpy8P7XwN04pTW3tW+B0E8Ij5wUK6OPvG9F8 jqRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BH1Dcbz1Lbyve4JvXaXPQ+ymNj6yEL+KSp99oMd8zbI=; b=v2rTuK4ckMoGS2Kxkb2JcTqSlFJD4Kd5xQ1lXQhWWCwgJu/3BPlpgufjI6t3+qGQQ1 iAtL+44ylXgPtpFiEwfpFByCkJMZgx71qoK1cCB8cP9tZEIBeN3D1P/GdV3nhbyf8Z7F jKuCr8DFxozSKPoyWq80MZughDJIBWUWaELf2mAzQE0xJX43Au8t7ygWGKkmSVp+Cfam 1/Fy/FIPZT0y2HpdHsAEo1kCsePv15HnewGmyFFShwM7mUGUvw53mkU35PXmrCThG79E ATCIuIfoolt0NOl4MfnAawLc4WS0p0+RGiS/8Wzzy1Oyvyeib4fBPTCOlhOudm7f3fwc Sfbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vnWMqpeT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a12-20020a1709027d8c00b00153b2d16512si13086561plm.282.2022.04.05.19.02.54; Tue, 05 Apr 2022 19:03:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vnWMqpeT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232404AbiDEM7u (ORCPT + 99 others); Tue, 5 Apr 2022 08:59:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242968AbiDEJId (ORCPT ); Tue, 5 Apr 2022 05:08:33 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F05B6237D1; Tue, 5 Apr 2022 01:57:25 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 526C4B81C6A; Tue, 5 Apr 2022 08:57:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8AA0AC385D2; Tue, 5 Apr 2022 08:57:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649149043; bh=4Z7OG637obt/kTnxZAjMu/EsUqkHgVZXwfQFr9p7fyE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vnWMqpeTbMSYmL23bKeKYyfV4CWPw1DZsw0KvBZdmYBYaCYPYfQsPaMYQkt3/f+hS y5RgE3/XVCMSNE6OC5MOEniHXJ0P1hKfB6flL2xgGQSCDgUROLcLU6SYCegxzb+p5p etPjclf/8k3nEcUKKp28eknC9ZwHu2QBWW6AFp04= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yajun Deng , Leon Romanovsky , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.16 0573/1017] RDMA/core: Fix ib_qp_usecnt_dec() called when error Date: Tue, 5 Apr 2022 09:24:46 +0200 Message-Id: <20220405070411.288282114@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yajun Deng [ Upstream commit 7c4a539ec38f4ce400a0f3fcb5ff6c940fcd67bb ] ib_destroy_qp() would called by ib_create_qp_user() if error, the former contains ib_qp_usecnt_dec(), but ib_qp_usecnt_inc() was not called before. So move ib_qp_usecnt_inc() into create_qp(). Fixes: d2b10794fc13 ("RDMA/core: Create clean QP creations interface for uverbs") Link: https://lore.kernel.org/r/20220303024232.2847388-1-yajun.deng@linux.dev Signed-off-by: Yajun Deng Reviewed-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/core/uverbs_cmd.c | 1 - drivers/infiniband/core/uverbs_std_types_qp.c | 1 - drivers/infiniband/core/verbs.c | 3 +-- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index d1345d76d9b1..5a99e31df5f5 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -1438,7 +1438,6 @@ static int create_qp(struct uverbs_attr_bundle *attrs, ret = PTR_ERR(qp); goto err_put; } - ib_qp_usecnt_inc(qp); obj->uevent.uobject.object = qp; obj->uevent.event_file = READ_ONCE(attrs->ufile->default_async_file); diff --git a/drivers/infiniband/core/uverbs_std_types_qp.c b/drivers/infiniband/core/uverbs_std_types_qp.c index dd1075466f61..75353e09c6fe 100644 --- a/drivers/infiniband/core/uverbs_std_types_qp.c +++ b/drivers/infiniband/core/uverbs_std_types_qp.c @@ -254,7 +254,6 @@ static int UVERBS_HANDLER(UVERBS_METHOD_QP_CREATE)( ret = PTR_ERR(qp); goto err_put; } - ib_qp_usecnt_inc(qp); if (attr.qp_type == IB_QPT_XRC_TGT) { obj->uxrcd = container_of(xrcd_uobj, struct ib_uxrcd_object, diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index e821dc94a43e..961055eb330d 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c @@ -1253,6 +1253,7 @@ static struct ib_qp *create_qp(struct ib_device *dev, struct ib_pd *pd, if (ret) goto err_security; + ib_qp_usecnt_inc(qp); rdma_restrack_add(&qp->res); return qp; @@ -1353,8 +1354,6 @@ struct ib_qp *ib_create_qp_kernel(struct ib_pd *pd, if (IS_ERR(qp)) return qp; - ib_qp_usecnt_inc(qp); - if (qp_init_attr->cap.max_rdma_ctxs) { ret = rdma_rw_init_mrs(qp, qp_init_attr); if (ret) -- 2.34.1