diff mbox series

[4/7] rasdaemon: fix memory leak in ras-events.c:add_event_handler()

Message ID 20191016163401.16980-5-shiju.jose@huawei.com (mailing list archive)
State Accepted
Headers show
Series rasdaemon: add fixes, database closure and signal handling | expand

Commit Message

Shiju Jose Oct. 16, 2019, 4:33 p.m. UTC
This patch rearranges the free(page) call to prevent the
memory leak when __toggle_ras_mc_event() fail.

Signed-off-by: Shiju Jose <shiju.jose@huawei.com>
---
 ras-events.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/ras-events.c b/ras-events.c
index fc6b288..f912dae 100644
--- a/ras-events.c
+++ b/ras-events.c
@@ -688,6 +688,7 @@  static int add_event_handler(struct ras_events *ras, struct pevent *pevent,
 
 	/* Enable RAS events */
 	rc = __toggle_ras_mc_event(ras, group, event, 1);
+	free(page);
 	if (rc < 0) {
 		log(TERM, LOG_ERR, "Can't enable %s:%s tracing\n",
 		    group, event);
@@ -697,7 +698,6 @@  static int add_event_handler(struct ras_events *ras, struct pevent *pevent,
 
 	log(ALL, LOG_INFO, "Enabled event %s:%s\n", group, event);
 
-	free(page);
 	return 0;
 }