Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1249715imw; Tue, 5 Jul 2022 06:25:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sSeXz6NjR5odHr1+g6GGHplxGrDf4OSIltrcKmVvMXlLWcQvm4xPk7FuXytkvzVZqWkP+E X-Received: by 2002:a17:907:72ce:b0:722:e1a5:164c with SMTP id du14-20020a17090772ce00b00722e1a5164cmr34478980ejc.111.1657027536913; Tue, 05 Jul 2022 06:25:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657027536; cv=none; d=google.com; s=arc-20160816; b=QcUzyJM5ArnUAKBq3cWefi8ZOlP2xeVyS/5wcbJmJl/CDNPJHVhdFqRkE1XwkToVr5 5kiK+w37SS16iQJkdgU16ULdVFGTDJJX794LmFDHCv3fLJ5ujgLGHPpVj9h1zBhRnEN9 Za8qhAqzloa28SDwBCoiqqNYRu+sPTDVVaSdhDD8IV/11VpOSyR32V2Hv+7KQX3qJtWl yGvSrx0/UoT3PYS0oahm2XJ9XP/xwlhESTX39T8ZDDCYY/tnIU2uVcT8GMtWPZZYMeow FEbuij0Afv+JYSr9fEBuBgwjEuQNmdDEMrDroS+fgZ4tm0lRSrXKyuseAe79a2o84eeo 5wkA== 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=HXf12fD7lXvg8RtDc5Tb6sOkiFipysEwSPxIVu2jCBg=; b=JN6/mRgcw4K4iqHQhLwYau8tcJv7CAEQ1hyONKtBix5ZJQQevh+BD9vIweDiQ6ZM8b M9wpp1ySgo3QYJH/B8aOoDrZGiQiZtXoCkQdreaSF42y3S7Knvo3g0jn3fngc4GdshVT +x+uyebhMmMrIsk8y0lO9ig3R+ZGG4fiDVGPf+/jwrI9/KF7mew+VaeLQ1BEgazl56+N ryO40v140NLtDcxP+tKjOEYmybT24/WaTBYaCexseCyREBxH53DEX30awmmeQAahwcpB y5y6itDUuffZ7xRKNeqsqCtQH1zcuf9KOnd2T3BpYymUPWTEqEXIyCwJz0veSBd+GyOl iLqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zfomB45i; 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 hq25-20020a1709073f1900b007269615d162si10322943ejc.236.2022.07.05.06.25.11; Tue, 05 Jul 2022 06:25:36 -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=zfomB45i; 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 S235526AbiGEMN6 (ORCPT + 99 others); Tue, 5 Jul 2022 08:13:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234812AbiGEMIA (ORCPT ); Tue, 5 Jul 2022 08:08:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8865819C0E; Tue, 5 Jul 2022 05:07:03 -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 AE7466185C; Tue, 5 Jul 2022 12:07:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B40C4C36AF2; Tue, 5 Jul 2022 12:07:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657022822; bh=p9Ok6rpgiTUosxVgNWnRJH6ar2JH1KUS+uf1ggRWfT8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zfomB45i1a5V7XtTi100Ka1MP5xAabSBoenUjoMb3X3p4cvRyi83h2TnA4NWodVBP Et9WNXJhTnTG4Vj3Qi7uvt6YK/VtUo5Y/CO8DfvvMQlEhS6lcASFFCopiOXi/xf8Bk BszXBlYTAzgmOAXObh98FK2gkHw95FoW222Nv0/8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Jason Gunthorpe Subject: [PATCH 5.10 22/84] RDMA/cm: Fix memory leak in ib_cm_insert_listen Date: Tue, 5 Jul 2022 13:57:45 +0200 Message-Id: <20220705115615.974240906@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220705115615.323395630@linuxfoundation.org> References: <20220705115615.323395630@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.8 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: Miaoqian Lin commit 2990f223ffa7bb25422956b9f79f9176a5b38346 upstream. cm_alloc_id_priv() allocates resource for the cm_id_priv. When cm_init_listen() fails it doesn't free it, leading to memory leak. Add the missing error unwind. Fixes: 98f67156a80f ("RDMA/cm: Simplify establishing a listen cm_id") Link: https://lore.kernel.org/r/20220621052546.4821-1-linmq006@gmail.com Signed-off-by: Miaoqian Lin Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/core/cm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c @@ -1280,8 +1280,10 @@ struct ib_cm_id *ib_cm_insert_listen(str return ERR_CAST(cm_id_priv); err = cm_init_listen(cm_id_priv, service_id, 0); - if (err) + if (err) { + ib_destroy_cm_id(&cm_id_priv->id); return ERR_PTR(err); + } spin_lock_irq(&cm_id_priv->lock); listen_id_priv = cm_insert_listen(cm_id_priv, cm_handler);