[PATCH] powerpc/pseries: fix memory leak in queue_hotplug_event() error path

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

STALE3609d

3 messages, 3 authors, 2016-09-20 · open the first message on its own page

[PATCH] powerpc/pseries: fix memory leak in queue_hotplug_event() error path

From: Andrew Donnellan <hidden>
Date: 2016-09-19 06:41:49

If we fail to allocate work, we don't end up using hp_errlog_copy. Free it
in the error path.

Signed-off-by: Andrew Donnellan <redacted>

---

Found by Coverity Scan. Compile tested only.
---
 arch/powerpc/platforms/pseries/dlpar.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
index 4748124..6a99e72 100644
--- a/arch/powerpc/platforms/pseries/dlpar.c
+++ b/arch/powerpc/platforms/pseries/dlpar.c
@@ -413,6 +413,7 @@ void queue_hotplug_event(struct pseries_hp_errorlog *hp_errlog,
 		queue_work(pseries_hp_wq, (struct work_struct *)work);
 	} else {
 		*rc = -ENOMEM;
+		kfree(hp_errlog_copy);
 		complete(hotplug_done);
 	}
 }
-- 
Andrew Donnellan              OzLabs, ADL Canberra
andrew.donnellan@au1.ibm.com  IBM Australia Limited

Re: [PATCH] powerpc/pseries: fix memory leak in queue_hotplug_event() error path

From: Nathan Fontenot <hidden>
Date: 2016-09-19 15:34:38

On 09/19/2016 01:41 AM, Andrew Donnellan wrote:
If we fail to allocate work, we don't end up using hp_errlog_copy. Free it
in the error path.

Signed-off-by: Andrew Donnellan <redacted>
Reviewed-by: Nathan Fontenot <redacted>
quoted hunk
---

Found by Coverity Scan. Compile tested only.
---
 arch/powerpc/platforms/pseries/dlpar.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
index 4748124..6a99e72 100644
--- a/arch/powerpc/platforms/pseries/dlpar.c
+++ b/arch/powerpc/platforms/pseries/dlpar.c
@@ -413,6 +413,7 @@ void queue_hotplug_event(struct pseries_hp_errorlog *hp_errlog,
 		queue_work(pseries_hp_wq, (struct work_struct *)work);
 	} else {
 		*rc = -ENOMEM;
+		kfree(hp_errlog_copy);
 		complete(hotplug_done);
 	}
 }

Re: powerpc/pseries: fix memory leak in queue_hotplug_event() error path

From: Michael Ellerman <hidden>
Date: 2016-09-20 13:07:20

On Mon, 2016-19-09 at 06:41:32 UTC, Andrew Donnellan wrote:
If we fail to allocate work, we don't end up using hp_errlog_copy. Free it
in the error path.

Signed-off-by: Andrew Donnellan <redacted>
Reviewed-by: Nathan Fontenot <redacted>
Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/90ce35145cb622b3cd0007d50e

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help