Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp646660ybh; Tue, 10 Mar 2020 05:48:28 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuHO/ngkpA8v+DR97BUwnEX3pAubf8gBbnWjohHk/Y8NGnQbe0/sy/kCDu+CFqn8Z57I87O X-Received: by 2002:a9d:6b1a:: with SMTP id g26mr8001538otp.2.1583844508195; Tue, 10 Mar 2020 05:48:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583844508; cv=none; d=google.com; s=arc-20160816; b=zeQT3BdI+9iWY4XCp20q2Pdl6UnGxQ+GGkGcdgmGkrXYv/kFoVWRriyWRFwD4DhVXq ymPAio0yq04m4FKvf984VeB/XX7j1EdG1AvuWcjDBpgTHaLscSjNTcRfGo13W3dnbw2U 9jFDRPJzDFhLe+IwdAbh5T/Y7vb1JBDGKf5tzap/XB6zwIR+stKxuRWsK5twG4IEDi9m cN4NIUF7zofZVVl+AXQ9uxbINk3vPkDzYbVWuGEFM+nj/JXoakr7fbfMc80GhK2eo5hD HD2ffRGP6vopu5PTuPg4yTt+7cgn8NM5fGtKEOXqqTFd0r0f9NbKTdTrZbGWTRIGA//t qrcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=B+KFlZI4PQvKHSK23cHHT717GmMped4cn+kW8BYguXI=; b=uio/eovExjxpk6aPu8/UVwr3tvKUdtSRMdtxH6xuSkUn+FxVl3VHyDoAFwhq7/jsFY 2U1FUH+JZU1cqmuGezm8iR0y5QdjoeC7edaNMize3GkJvYq2FVN2SR705gaRG/GhaToU DN2t4KO4edFE5RxIZ7y/SlPu5r0xa02pvp5JB2T6G3KPbj/13j/6XCNlu9MB7I75zL5O tQ5uYbl2XzyXZCbBmdmjTtS0qRGNBNRMwj8uGKZQuQQF9ja0H3OHlbPkd/LoivBVtu8m HH9Jxsep9JQ/V166GhtkHcIc35ZgrGbCH+3U+xUCVrAYa6wBYK/ewzZMXXYMuLui05h0 R8+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=datS4WqD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m126si4853705oig.177.2020.03.10.05.48.16; Tue, 10 Mar 2020 05:48:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=datS4WqD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728156AbgCJMrT (ORCPT + 99 others); Tue, 10 Mar 2020 08:47:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:51082 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727916AbgCJMrR (ORCPT ); Tue, 10 Mar 2020 08:47:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6429320674; Tue, 10 Mar 2020 12:47:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583844436; bh=xVHPfJwgpy+80zOCWhcXFojkR2XjvT3blf7cFg0/OCg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=datS4WqDTjhcMPYs1VCBXJTAXN1JV4lqJqgQQxrbuwtDkyRCYhK/83EoqriYti6q7 HEpSQYmCMg7gI0LzwUJQvgbroSUM1voMnOGWpQjwnLWBR2NUZk+ZGBuCb+zTJ8bYRF tZzDfz8SlcTNwoT6uucr9TGo09APR3TGKZv2oR3s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jason Gunthorpe Subject: [PATCH 4.9 82/88] RMDA/cm: Fix missing ib_cm_destroy_id() in ib_cm_insert_listen() Date: Tue, 10 Mar 2020 13:39:30 +0100 Message-Id: <20200310123624.696596703@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200310123606.543939933@linuxfoundation.org> References: <20200310123606.543939933@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jason Gunthorpe commit c14dfddbd869bf0c2bafb7ef260c41d9cebbcfec upstream. The algorithm pre-allocates a cm_id since allocation cannot be done while holding the cm.lock spinlock, however it doesn't free it on one error path, leading to a memory leak. Fixes: 067b171b8679 ("IB/cm: Share listening CM IDs") Link: https://lore.kernel.org/r/20200221152023.GA8680@ziepe.ca Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/core/cm.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c @@ -1073,6 +1073,7 @@ struct ib_cm_id *ib_cm_insert_listen(str /* Sharing an ib_cm_id with different handlers is not * supported */ spin_unlock_irqrestore(&cm.lock, flags); + ib_destroy_cm_id(cm_id); return ERR_PTR(-EINVAL); } atomic_inc(&cm_id_priv->refcount);