From patchwork Fri Jan 24 09:26:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 233029 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A863CC35242 for ; Fri, 24 Jan 2020 11:10:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 751D12071A for ; Fri, 24 Jan 2020 11:10:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579864228; bh=NxKSitTLrFjxskMIQYHG79kRZzyxU4AyPUZPCgK1PQ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=myeMt8xSiClsHuP7nSrsOzdGzX+qOmvSEW3/IfZGujnr9iuA5yXaarMnUU+oI7WzJ uzNcW1qi7UWGNFNzXtSEPHfTuy7k0eX/pH98H4CpT37er7NpoHwy+l5ZarvplI8tsF usIVbueK6An0856I3CfQ5h0AZxen4nGC+FX3Q+hg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731494AbgAXLK1 (ORCPT ); Fri, 24 Jan 2020 06:10:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:46210 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387777AbgAXLK0 (ORCPT ); Fri, 24 Jan 2020 06:10:26 -0500 Received: from localhost (ip-213-127-102-57.ip.prioritytelecom.net [213.127.102.57]) (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 AEE8220708; Fri, 24 Jan 2020 11:10:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579864226; bh=NxKSitTLrFjxskMIQYHG79kRZzyxU4AyPUZPCgK1PQ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KWPuvBFr+i3TFdLoF6H+afi4L6EkCq7WYCMf4z+ha8jBl1o8VBYtcqnpDGHkv81cy 3zeuXmKldWKp+unLa0xn/JKDsvOWLzHcjzqOluoSDOtLzDE26mJ5CnTUdyJs11bilt qN8C/1++lh1HRCqOeSNjFfwVi39tkJML0VJl/FCY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Bloch , Bodong Wang , =?utf-8?q?H=C3=A5kon_Bugge?= , Leon Romanovsky , Jason Gunthorpe , Sasha Levin Subject: [PATCH 4.19 194/639] RDMA/mlx5: Fix memory leak in case we fail to add an IB device Date: Fri, 24 Jan 2020 10:26:04 +0100 Message-Id: <20200124093111.376671852@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200124093047.008739095@linuxfoundation.org> References: <20200124093047.008739095@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Mark Bloch [ Upstream commit fc9e4477f924e84d7798f7a1d41401d699de1219 ] Make sure the IB device is freed on failure. Fixes: b5ca15ad7e61 ("IB/mlx5: Add proper representors support") Signed-off-by: Mark Bloch Reviewed-by: Bodong Wang Reviewed-by: HÃ¥kon Bugge Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/hw/mlx5/ib_rep.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/mlx5/ib_rep.c b/drivers/infiniband/hw/mlx5/ib_rep.c index 35a0e04c38f28..b841589c27c9c 100644 --- a/drivers/infiniband/hw/mlx5/ib_rep.c +++ b/drivers/infiniband/hw/mlx5/ib_rep.c @@ -69,8 +69,10 @@ mlx5_ib_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep) ibdev->mdev = dev; ibdev->num_ports = max(MLX5_CAP_GEN(dev, num_ports), MLX5_CAP_GEN(dev, num_vhca_ports)); - if (!__mlx5_ib_add(ibdev, &rep_profile)) + if (!__mlx5_ib_add(ibdev, &rep_profile)) { + ib_dealloc_device(&ibdev->ib_dev); return -EINVAL; + } rep->rep_if[REP_IB].priv = ibdev;