From mboxrd@z Thu Jan 1 00:00:00 1970 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=-6.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 C8939C34031 for ; Tue, 18 Feb 2020 21:07:32 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4029B2176D for ; Tue, 18 Feb 2020 21:07:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Vi8WvkiH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4029B2176D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48MYMh72nfzDqGX for ; Wed, 19 Feb 2020 08:07:28 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=redhat.com (client-ip=205.139.110.61; helo=us-smtp-delivery-1.mimecast.com; envelope-from=jmoyer@redhat.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Vi8WvkiH; dkim-atps=neutral Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48MYH32PsVzDqcq for ; Wed, 19 Feb 2020 08:03:26 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582059802; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Vvczn1/7WH5ejB4qaPLsHmvxrtLN/Bp15yKQpp7R6F0=; b=Vi8WvkiHr6A2v12fdCr8wYyXZvdEijuW8Z70A3JeQH/kSwP7zw+36kpIdCTDziFzhr1eH+ j6O9kcufSMA99jZUhSva1lfcTWZpyqPP7Q/38peHi63uM0P9m1TFCEWpJEQ8DjKbqCEdJY w9/1zO/YdK0q2wGGFvUuiYZBxSl0kFE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-418-c49ZyBenPCSX0r2KfBpWTg-1; Tue, 18 Feb 2020 16:03:15 -0500 X-MC-Unique: c49ZyBenPCSX0r2KfBpWTg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EC5FE107ACC4; Tue, 18 Feb 2020 21:03:13 +0000 (UTC) Received: from segfault.boston.devel.redhat.com (segfault.boston.devel.redhat.com [10.19.60.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4C5C819E9C; Tue, 18 Feb 2020 21:03:13 +0000 (UTC) From: Jeff Moyer To: Vaibhav Jain Subject: Re: [PATCH] libnvdimm/of_pmem: Fix leaking bus_desc.provider_name in some paths References: <20200123031847.149325-1-vaibhav@linux.ibm.com> X-PGP-KeyID: 1F78E1B4 X-PGP-CertKey: F6FE 280D 8293 F72C 65FD 5A58 1FF8 A7CA 1F78 E1B4 Date: Tue, 18 Feb 2020 16:03:12 -0500 In-Reply-To: <20200123031847.149325-1-vaibhav@linux.ibm.com> (Vaibhav Jain's message of "Thu, 23 Jan 2020 08:48:47 +0530") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Aneesh Kumar K . V" , linuxppc-dev@lists.ozlabs.org, stable@vger.kernel.org, linux-nvdimm@lists.01.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Vaibhav Jain writes: > String 'bus_desc.provider_name' allocated inside > of_pmem_region_probe() will leak in case call to nvdimm_bus_register() > fails or when of_pmem_region_remove() is called. > > This minor patch ensures that 'bus_desc.provider_name' is freed in > error path for of_pmem_region_probe() as well as in > of_pmem_region_remove(). > > Cc: stable@vger.kernel.org > Fixes:49bddc73d15c2("libnvdimm/of_pmem: Provide a unique name for bus provider") > Signed-off-by: Vaibhav Jain > --- > drivers/nvdimm/of_pmem.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/nvdimm/of_pmem.c b/drivers/nvdimm/of_pmem.c > index 8224d1431ea9..9cb76f9837ad 100644 > --- a/drivers/nvdimm/of_pmem.c > +++ b/drivers/nvdimm/of_pmem.c > @@ -36,6 +36,7 @@ static int of_pmem_region_probe(struct platform_device *pdev) > > priv->bus = bus = nvdimm_bus_register(&pdev->dev, &priv->bus_desc); > if (!bus) { > + kfree(priv->bus_desc.provider_name); > kfree(priv); > return -ENODEV; > } > @@ -81,6 +82,7 @@ static int of_pmem_region_remove(struct platform_device *pdev) > struct of_pmem_private *priv = platform_get_drvdata(pdev); > > nvdimm_bus_unregister(priv->bus); > + kfree(priv->bus_desc.provider_name); > kfree(priv); > > return 0; Reviewed-by: Jeff Moyer