Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp685996ybv; Thu, 13 Feb 2020 07:45:34 -0800 (PST) X-Google-Smtp-Source: APXvYqw+StA3Y8xwNMmUL3w7/FYxlkFrSGxNYR67iaevUbYnjRCK9ejBVJeC8oL3i/D1+7RL9AdO X-Received: by 2002:aca:c692:: with SMTP id w140mr3412171oif.139.1581608734341; Thu, 13 Feb 2020 07:45:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581608734; cv=none; d=google.com; s=arc-20160816; b=0ibPqwt64GmnMa6a0cny3y7lHrB6ollr3JuHJNwpY8Qe91z93xw4knmjALXP8UsU2l lXFLfG2YIWPiQz5y4lW+eLzGDpwMgihh8kxPbKpFVQnkiOCljjBngeiueiE4/XdapE9j ZOXnnL54fbN3RuJmfqi/eLID6N0CR4gYi7bBCHybGfWLPFb2ZQQp1LYUjZEp0X3xY6LX p1+3ce1gZmHInJ9jSaz0NA6f86R7MNCv76sfUEhvunZZu1XVAdlgIkEZ6Vg/0jjH636h e/3fzIGYAzLtpGOxuZeOkd48xmwhwVMYQYBvH2xwLKA2+NHOa1A3Kw0nOsn163yHsgm6 mfeQ== 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=ssIIRPoUTDZjicY8PjZ1yRm6cGxNwVMgSd/QnXbUNrA=; b=wcmvg9xSFE5ZZ3k1g1dsNRu1toPnEFl8ZjIw7OVabD7Tnsc+1bC4yAhwJW6IL0k00B RvPXOmvwpnycwke9FDQA/44xkiFNHbkU2DOXlIzWeRCwOWdoBve4eGNnp8Y3kiviM8CJ jMFoeIgOhxrcVQLMvp/Ewu1XphgecBZHF0vpn+G2JPZxFyr5COcN2Pnp3jjo9U1DGaT3 LDA1RKVsS1vAH4/OgHPCeFmTatk2fTIRW/CIyLGdkkcHYcvlshfvnzsNt8yFWSb/39bW HEJ8HLkeNn3ISn0gEa7bc/4VUU5QE10Vlfj89q/PMEqU+fDwt2fokVWhtO73B0AcqNXM zizA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=x7jdKUAd; 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 w207si1241691oie.111.2020.02.13.07.45.22; Thu, 13 Feb 2020 07:45:34 -0800 (PST) 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=x7jdKUAd; 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 S1729928AbgBMPpR (ORCPT + 99 others); Thu, 13 Feb 2020 10:45:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:51104 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728612AbgBMP1d (ORCPT ); Thu, 13 Feb 2020 10:27:33 -0500 Received: from localhost (unknown [104.132.1.104]) (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 CACAE20661; Thu, 13 Feb 2020 15:27:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581607651; bh=ykTPePhQ0hHddIuGcVzpNHQS8K4ncWoU9fS/eVv0JTs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x7jdKUAd4oFtswdvmpi5uzd0GRXXu3SdiKK6HCzZDlM6MEC++oo0aav121tka1Fbh O9AQn2CcAcVfv+uKtkZ35ISvUnQkjytKDNj/QZCASwUzfrdb4R2+Xs8iUMnnkhdqrL vAiJetIiU2PlBR2d69Tduk20NeZtL1ruVSp1WQVA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vaibhav Jain , Michael Ellerman Subject: [PATCH 5.4 56/96] powerpc/papr_scm: Fix leaking bus_desc.provider_name in some paths Date: Thu, 13 Feb 2020 07:21:03 -0800 Message-Id: <20200213151901.020531511@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213151839.156309910@linuxfoundation.org> References: <20200213151839.156309910@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: Vaibhav Jain commit 5649607a8d0b0e019a4db14aab3de1e16c3a2b4f upstream. String 'bus_desc.provider_name' allocated inside papr_scm_nvdimm_init() will leaks in case call to nvdimm_bus_register() fails or when papr_scm_remove() is called. This minor patch ensures that 'bus_desc.provider_name' is freed in error path for nvdimm_bus_register() as well as in papr_scm_remove(). Fixes: b5beae5e224f ("powerpc/pseries: Add driver for PAPR SCM regions") Signed-off-by: Vaibhav Jain Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20200122155140.120429-1-vaibhav@linux.ibm.com Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/platforms/pseries/papr_scm.c | 2 ++ 1 file changed, 2 insertions(+) --- a/arch/powerpc/platforms/pseries/papr_scm.c +++ b/arch/powerpc/platforms/pseries/papr_scm.c @@ -342,6 +342,7 @@ static int papr_scm_nvdimm_init(struct p p->bus = nvdimm_bus_register(NULL, &p->bus_desc); if (!p->bus) { dev_err(dev, "Error creating nvdimm bus %pOF\n", p->dn); + kfree(p->bus_desc.provider_name); return -ENXIO; } @@ -498,6 +499,7 @@ static int papr_scm_remove(struct platfo nvdimm_bus_unregister(p->bus); drc_pmem_unbind(p); + kfree(p->bus_desc.provider_name); kfree(p); return 0;