Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp936967pxb; Wed, 6 Apr 2022 04:48:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwOXrMBasaLGEFf/+CtaGBIUc+JzAwyx0n5keppRXmv/C+4ZYl1TpnioXmJpdpPJqKVptO X-Received: by 2002:a63:3718:0:b0:398:1086:e8ec with SMTP id e24-20020a633718000000b003981086e8ecmr6916754pga.498.1649245733746; Wed, 06 Apr 2022 04:48:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649245733; cv=none; d=google.com; s=arc-20160816; b=05aZFzlKdWzJySspEQI+99HZiitVHMEoRzbIz6L5fnAmdydAkTm83enM6h2FXzS0M2 84Z8+0kF8EgvYX+ONTnLe8k/XGLFrn8aPORqYqBTpX8/DWXZSeFAdunhIzRREpOkxcDz tyLT6y+vs04wBqn7wtTfotBpedXJzfpJr+yQyitpCcwHwX6alcrO3iJx5Cjddc1Iww67 PLy3qsmZfj8cz38J+AXjHTCSeu4RW2oioiMuNyWyqDn05GFlgacy5S/zPm/sE4kjhYcO wqxRWTwS4XTSk1OWGCX4M3xya4PyBvUogyvWNVFgLZAb8C0iYnP6M6Cs+EVO+lhkTyMn 9YrQ== 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=RbZHrOvqcYS2/IuYr30w4OiYmfo3jbaMiHkVE6TR9/0=; b=ZLxfQ7aHv4M+aRqMTY1NjQM7beYlY+J/COIgDKaQAk4YRXBINlInFFbrVRJCGgHd0F Bi+Qz5hj7U6LH447n/zr9l0HkFOl9lQKSHu8KTz+EcVwue6Mq1y71QRAkyTtpR13sR6r GQuxgxdaCGVTW/6Dyxs/d7xEJR/TmUqMjDQgyPmGyrgRoLczvyA4vehS0dMkO7mH6pdj SU2+WeolOZ1Rp1t+8lXaNn/wP0PSCNQfr1oZeMhej9jR2RW1ChDi6F19KvKRVwj+qr1P YwKbCURpHrDQX83O7LBba4hBE2H3AgOQXUOu/SzT/XxlUu/Z8y694618e1lHUxZ+EA3w m6wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vHYZXIAK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d8-20020a170902cec800b00156f4ea74b7si348912plg.571.2022.04.06.04.48.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 04:48:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vHYZXIAK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0EA7D2CF153; Wed, 6 Apr 2022 03:07:03 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244714AbiDEXnq (ORCPT + 99 others); Tue, 5 Apr 2022 19:43:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349166AbiDEJtW (ORCPT ); Tue, 5 Apr 2022 05:49:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0006164D6; Tue, 5 Apr 2022 02:41:57 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 909E86164D; Tue, 5 Apr 2022 09:41:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E50EC385A1; Tue, 5 Apr 2022 09:41:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649151717; bh=jYK5sFnekXCxVL58RTzjeUc9TcSXOqyPwQlvV9P1BcY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vHYZXIAK1tkF/d5N1ks0pF+yE15AtpZlLteVT4QuLR4oL7A16O6gNIlXpQ6OERy6A ssLUVQ7ihEu5bokL1s1MeFiezSgheMuJsNfTp8ttO7MCZUZk3adCVvDHZ4eWEcsRyv QrPwF+xBn6tNs6IHpjz0UvRh/pJkH+7va8GmgdgY= 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.15 516/913] RDMA/core: Fix ib_qp_usecnt_dec() called when error Date: Tue, 5 Apr 2022 09:26:18 +0200 Message-Id: <20220405070355.320834170@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 59e20936b800..b78cd65d20a6 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