Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4140184ybe; Mon, 9 Sep 2019 05:01:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqx6oYgnxteLoLwAhKnMo5RVjOZt06BUTBaNF7OEGbjlvykDuHeCyqDXeXz0QxirEqIbytwY X-Received: by 2002:a17:906:31c3:: with SMTP id f3mr19409894ejf.296.1568030512081; Mon, 09 Sep 2019 05:01:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568030512; cv=none; d=google.com; s=arc-20160816; b=WD7Y8Sn/qOu4nhUWMaHLqM1WSf2VMQnnHipNXZ7kt1XiKsw8cqqDhps0zw6BlyN4so da7Yrf1qpzQl0CVvJjv3fDte4+N9+A2u3AKLIkRSAnAGHERmnVMX4NyqfvG568E19KEM OvPG+aKChKLmggeqAiCUHH0Ca56s9ga3VWC9jL/hb5CuHnd80op4fiKAQJjdP7QAEe4i DKMmIlPZHISRVJj4hSv8FRidNqC7uoXmj3lygolvKpFQnqg/XY8ymya4fZiUe94UF1G2 8bfOXrcly6i6vUlbfyREiD+43N3KFoeo5uJZ7iEj0th4A745Q/UKyzAprpOux8lT+qmM kelw== 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=BYS2qNKdgPmpq4yoxO/rfSVfX17rGdBR4yrnEn4YS6c=; b=S/UQOzvrV7ZF3m4Pbj4engXqgQxZYo1l9lHSPHUjkX7gNUlBnRzfSKJA3rCmi3+E+n 2uLAEJulVYe5kH0KbdUoqsZHHDwyWmJToXK9FaL24xCHEUtTBc8XztCCe7GAFqB6SiBI +TLTBsir1Ej7WpWbqCCnqd4FhxYLEzld0gtPW2mc/jsYIXzNvkUPAAnFbLiAbnnLm33W TVncUvmVpsOuMxErqOEa5qnRhFb/d/H5S7nciPYg8IOAItWf7vs9Q7KHE11Kc+p58z6t bhn2DaJjxDrUqbMGJ002/ewpkrsFpoDI2Q8rmbhDGDcjA8fI0h1T6FHaD2bDF8v0cG6A c3uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fkUVXFCw; 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 a19si7250466eje.361.2019.09.09.05.01.22; Mon, 09 Sep 2019 05:01:52 -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=fkUVXFCw; 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 S1732986AbfIHMwU (ORCPT + 99 others); Sun, 8 Sep 2019 08:52:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:44254 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732922AbfIHMwL (ORCPT ); Sun, 8 Sep 2019 08:52:11 -0400 Received: from localhost (unknown [62.28.240.114]) (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 CE79F218AC; Sun, 8 Sep 2019 12:52:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567947131; bh=qOH17Mx2wNpe6Xc+FAHIf4Z6likbmzKYix05DTI5m6s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fkUVXFCwyhip1v9Xsxnjj9NCTUURWoU5J35HsiIaQt+FD5kREkpq7ivCzxWP69hje HWTgHWO7d1rLyYYsQ/s9786E9dBOjLdSAd1v9i4TAZHCfo0NWrZpjJ4OjizdhCcI0R CIY6CxJySuBr5AqPMn+cCKIhPa9ak3GKdluJNGqU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , zhengbin , Parav Pandit , Doug Ledford , Sasha Levin Subject: [PATCH 5.2 73/94] RDMA/cma: fix null-ptr-deref Read in cma_cleanup Date: Sun, 8 Sep 2019 13:42:09 +0100 Message-Id: <20190908121152.523231583@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190908121150.420989666@linuxfoundation.org> References: <20190908121150.420989666@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 [ Upstream commit a7bfb93f0211b4a2f1ffeeb259ed6206bac30460 ] In cma_init, if cma_configfs_init fails, need to free the previously memory and return fail, otherwise will trigger null-ptr-deref Read in cma_cleanup. cma_cleanup cma_configfs_exit configfs_unregister_subsystem Fixes: 045959db65c6 ("IB/cma: Add configfs for rdma_cm") Reported-by: Hulk Robot Signed-off-by: zhengbin Reviewed-by: Parav Pandit Link: https://lore.kernel.org/r/1566188859-103051-1-git-send-email-zhengbin13@huawei.com Signed-off-by: Doug Ledford Signed-off-by: Sasha Levin --- drivers/infiniband/core/cma.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 19f1730a4f244..a68d0ccf67a43 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -4724,10 +4724,14 @@ static int __init cma_init(void) if (ret) goto err; - cma_configfs_init(); + ret = cma_configfs_init(); + if (ret) + goto err_ib; return 0; +err_ib: + ib_unregister_client(&cma_client); err: unregister_netdevice_notifier(&cma_nb); ib_sa_unregister_client(&sa_client); -- 2.20.1