linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
To: Vaibhav Jain <vaibhav@linux.ibm.com>, linuxppc-dev@lists.ozlabs.org
Cc: Oliver O'Halloran <oohall@gmail.com>
Subject: Re: [PATCH] powerpc/papr_scm: Fix leaking 'bus_desc.provider_name' in some paths
Date: Wed, 22 Jan 2020 22:25:14 +0530	[thread overview]
Message-ID: <b1d1505d-f432-a626-018b-ce8e4e1b6bce@linux.ibm.com> (raw)
In-Reply-To: <20200122155140.120429-1-vaibhav@linux.ibm.com>

On 1/22/20 9:21 PM, Vaibhav Jain wrote:
> 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().
> 
> Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
> ---
>   arch/powerpc/platforms/pseries/papr_scm.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/arch/powerpc/platforms/pseries/papr_scm.c b/arch/powerpc/platforms/pseries/papr_scm.c
> index c2ef320ba1bf..eb420655ed0b 100644
> --- a/arch/powerpc/platforms/pseries/papr_scm.c
> +++ b/arch/powerpc/platforms/pseries/papr_scm.c
> @@ -322,6 +322,7 @@ static int papr_scm_nvdimm_init(struct papr_scm_priv *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;
>   	}
>   
> @@ -477,6 +478,7 @@ static int papr_scm_remove(struct platform_device *pdev)
>   
>   	nvdimm_bus_unregister(p->bus);
>   	drc_pmem_unbind(p);
> +	kfree(p->bus_desc.provider_name);
>   	kfree(p);
>   
>   	return 0;
> 

Add similar error handling to of-pmem driver too?

-aneesh


  reply	other threads:[~2020-01-22 16:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-22 15:51 [PATCH] powerpc/papr_scm: Fix leaking 'bus_desc.provider_name' in some paths Vaibhav Jain
2020-01-22 16:55 ` Aneesh Kumar K.V [this message]
2020-01-29  5:17 ` Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b1d1505d-f432-a626-018b-ce8e4e1b6bce@linux.ibm.com \
    --to=aneesh.kumar@linux.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=oohall@gmail.com \
    --cc=vaibhav@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).