Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2691323ybl; Thu, 29 Aug 2019 11:32:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4uuftkvYRAT1V6MNJhuuRSvZ4+RI8HDlfEYq39Wzbtm7AhdiKulnqcUSeare0Oy/96UVx X-Received: by 2002:a17:90a:650c:: with SMTP id i12mr11331381pjj.11.1567103531963; Thu, 29 Aug 2019 11:32:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567103531; cv=none; d=google.com; s=arc-20160816; b=OUNqrlRAbb+z9mpOl8Pf+EXAIUKvVfEJ3FVf+mgAIaJleshfUIjhQDnGOEyVuG6hES 8wYxFHc200VljTf+JQDP3W1rXg+ocmEKflMoWr0KEaMcKfsYVIQTwJuzyzZwa2JEjaeY 6vAJDf2eSiuiglPPw5gkoULWlU2WWKHECvY+he7j+6wZRdVPis+8S+0IgSu+DyPkVNJN cnxqAEu+5pZaTeH4Q7zOmnS9ijsFLy0Y2wyxPnIn1dRDYYPRMikOvKTLyfL5SRRisT6Q a960JNgydfeZIB8tjW3IEu+JxzTgJe9XAefmOxglDorJuLKPPg26/dXssBVK6S2/IfgH JVTQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5nfmqmwVmF5OXjnX8ahQ/Z/y9fuI8o7+o6+xlK8iHAc=; b=Fac5DG7MK8nJlQdqNBL0/Ka2O2qiSOszLwYjji3M5ebXcXrM7WfMK1SBh659j5m/hB lCR3ZAi4b9Q9WU1R6uHejQ1etbIgCeNwzP9Xz38s33WGT77xuIVpKMw68R7/1N202hl/ nhq3p6hhAu44MfK11O7ll9zXd/yC8n3mU8Cm+MnNsUsjTaAHq5hRCGZ7sLWpDpStHyWq jfWylKkx6ldGCusw/G2abu+gnJFwW0GfsAlJXacZZrAgt1qwiIhnJWdwEKQOqfWUVFV+ zq5v2i+FoYOTNuerdoWKV5cCjRLPJK6nOL9keivbt4VdDLCDDfZRA4rqsYE24sgVPtZ2 8bmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lRCAPTdO; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i24si2054265pfr.66.2019.08.29.11.31.56; Thu, 29 Aug 2019 11:32:11 -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=lRCAPTdO; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729333AbfH2S25 (ORCPT + 99 others); Thu, 29 Aug 2019 14:28:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:56894 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729184AbfH2SPL (ORCPT ); Thu, 29 Aug 2019 14:15:11 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 409A82189D; Thu, 29 Aug 2019 18:15:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567102511; bh=ZRphFBhD0xKR03GxL0DcPOuwSe/QgK3Rp3TsN7hYc6c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lRCAPTdOFpF/5TZ7HCW6Ddf8MuF967EaKBjZ/KtOJv8ry3pVuQ+nGTNf27Z0c7XDq CkA3KMS7Nm7bW1u1vNo3yUaYNsg1bVVjn3xzpYOYKZGlJKVwF2mFouP2oimJr70DPC P/I1Y5ksc60hnBUddi80FaWqE4ZtCsuFZ56WIZI8= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: zhengbin , Hulk Robot , Parav Pandit , Doug Ledford , Sasha Levin , linux-rdma@vger.kernel.org Subject: [PATCH AUTOSEL 5.2 59/76] RDMA/cma: fix null-ptr-deref Read in cma_cleanup Date: Thu, 29 Aug 2019 14:12:54 -0400 Message-Id: <20190829181311.7562-59-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190829181311.7562-1-sashal@kernel.org> References: <20190829181311.7562-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: zhengbin [ 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