[PATCH] powerpc/papr_scm: Fix leaking 'bus_desc.provider_name' in some paths
Aneesh Kumar K.V
aneesh.kumar at linux.ibm.com
Thu Jan 23 03:55:14 AEDT 2020
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 at 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
More information about the Linuxppc-dev
mailing list