All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/papr_scm: Fix leaking 'bus_desc.provider_name' in some paths
@ 2020-01-22 15:51 Vaibhav Jain
  2020-01-22 16:55 ` Aneesh Kumar K.V
  2020-01-29  5:17 ` Michael Ellerman
  0 siblings, 2 replies; 3+ messages in thread
From: Vaibhav Jain @ 2020-01-22 15:51 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Vaibhav Jain, Oliver O'Halloran, Aneesh Kumar K . V

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;
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] powerpc/papr_scm: Fix leaking 'bus_desc.provider_name' in some paths
  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
  2020-01-29  5:17 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Aneesh Kumar K.V @ 2020-01-22 16:55 UTC (permalink / raw)
  To: Vaibhav Jain, linuxppc-dev; +Cc: Oliver O'Halloran

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] powerpc/papr_scm: Fix leaking 'bus_desc.provider_name' in some paths
  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
@ 2020-01-29  5:17 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2020-01-29  5:17 UTC (permalink / raw)
  To: Vaibhav Jain, linuxppc-dev
  Cc: Vaibhav Jain, Oliver O'Halloran, Aneesh Kumar K . V

On Wed, 2020-01-22 at 15:51:40 UTC, 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>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/5649607a8d0b0e019a4db14aab3de1e16c3a2b4f

cheers

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-29  6:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2020-01-29  5:17 ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.