diff mbox

drivers/perf: arm_pmu_acpi: Release memory obtained by kasprintf

Message ID f3b19a8ba9ca69fe84b0d980b6337a33a1da907d.1505884534.git.arvind.yadav.cs@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Arvind Yadav Sept. 20, 2017, 6:56 a.m. UTC
Free memory region, if arm_pmu_acpi_probe is not successful.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/perf/arm_pmu_acpi.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Will Deacon Sept. 22, 2017, 10:54 a.m. UTC | #1
On Wed, Sep 20, 2017 at 12:26:38PM +0530, Arvind Yadav wrote:
> Free memory region, if arm_pmu_acpi_probe is not successful.
> 
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> ---
>  drivers/perf/arm_pmu_acpi.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/perf/arm_pmu_acpi.c b/drivers/perf/arm_pmu_acpi.c
> index 0a9b787..3303dd8 100644
> --- a/drivers/perf/arm_pmu_acpi.c
> +++ b/drivers/perf/arm_pmu_acpi.c
> @@ -235,6 +235,7 @@ int arm_pmu_acpi_probe(armpmu_init_fn init_fn)
>  		ret = armpmu_register(pmu);
>  		if (ret) {
>  			pr_warn("Failed to register PMU for CPU%d\n", cpu);
> +			kfree(pmu->name);
>  			return ret;
>  		}
>  	}

It's a bit weird that we bail out of the loop on the first failing CPU, but
you've not changed that behaviour so your patch looks fine in isolation:

Acked-by: Will Deacon <will.deacon@arm.com>

Catalin: can you pick this up as a fix, please?

Will
Catalin Marinas Sept. 22, 2017, 2:12 p.m. UTC | #2
On Fri, Sep 22, 2017 at 11:54:06AM +0100, Will Deacon wrote:
> On Wed, Sep 20, 2017 at 12:26:38PM +0530, Arvind Yadav wrote:
> > Free memory region, if arm_pmu_acpi_probe is not successful.
> > 
> > Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> > ---
> >  drivers/perf/arm_pmu_acpi.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/perf/arm_pmu_acpi.c b/drivers/perf/arm_pmu_acpi.c
> > index 0a9b787..3303dd8 100644
> > --- a/drivers/perf/arm_pmu_acpi.c
> > +++ b/drivers/perf/arm_pmu_acpi.c
> > @@ -235,6 +235,7 @@ int arm_pmu_acpi_probe(armpmu_init_fn init_fn)
> >  		ret = armpmu_register(pmu);
> >  		if (ret) {
> >  			pr_warn("Failed to register PMU for CPU%d\n", cpu);
> > +			kfree(pmu->name);
> >  			return ret;
> >  		}
> >  	}
> 
> It's a bit weird that we bail out of the loop on the first failing CPU, but
> you've not changed that behaviour so your patch looks fine in isolation:
> 
> Acked-by: Will Deacon <will.deacon@arm.com>
> 
> Catalin: can you pick this up as a fix, please?

Applied. Thanks.
diff mbox

Patch

diff --git a/drivers/perf/arm_pmu_acpi.c b/drivers/perf/arm_pmu_acpi.c
index 0a9b787..3303dd8 100644
--- a/drivers/perf/arm_pmu_acpi.c
+++ b/drivers/perf/arm_pmu_acpi.c
@@ -235,6 +235,7 @@  int arm_pmu_acpi_probe(armpmu_init_fn init_fn)
 		ret = armpmu_register(pmu);
 		if (ret) {
 			pr_warn("Failed to register PMU for CPU%d\n", cpu);
+			kfree(pmu->name);
 			return ret;
 		}
 	}