forked from Minki/linux
powerpc/papr_scm: Fix leaking 'bus_desc.provider_name' in some paths
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: b5beae5e22
("powerpc/pseries: Add driver for PAPR SCM regions")
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200122155140.120429-1-vaibhav@linux.ibm.com
This commit is contained in:
parent
493a55f1e7
commit
5649607a8d
@ -323,6 +323,7 @@ static int papr_scm_nvdimm_init(struct papr_scm_priv *p)
|
|||||||
p->bus = nvdimm_bus_register(NULL, &p->bus_desc);
|
p->bus = nvdimm_bus_register(NULL, &p->bus_desc);
|
||||||
if (!p->bus) {
|
if (!p->bus) {
|
||||||
dev_err(dev, "Error creating nvdimm bus %pOF\n", p->dn);
|
dev_err(dev, "Error creating nvdimm bus %pOF\n", p->dn);
|
||||||
|
kfree(p->bus_desc.provider_name);
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -477,6 +478,7 @@ static int papr_scm_remove(struct platform_device *pdev)
|
|||||||
|
|
||||||
nvdimm_bus_unregister(p->bus);
|
nvdimm_bus_unregister(p->bus);
|
||||||
drc_pmem_unbind(p);
|
drc_pmem_unbind(p);
|
||||||
|
kfree(p->bus_desc.provider_name);
|
||||||
kfree(p);
|
kfree(p);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user