From 4538bc1c819e07aaf8c10553367690c4059f1b26 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 11 Jan 2017 01:16:07 +0000 Subject: [PATCH] scst: Fix a memory leak Avoid that the memory allocated for struct scst_acn and its name is leaked by scst_del_acg(). git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7090 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_lib.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 22fe0dbb1..a35fbfd04 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -79,7 +79,6 @@ static void scst_put_acg_work(void *p); #else static void scst_put_acg_work(struct work_struct *work); #endif -static void scst_del_acn(struct scst_acn *acn); static void scst_free_acn(struct scst_acn *acn, bool reassign); #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) @@ -4681,7 +4680,7 @@ out_free: */ static void scst_del_acg(struct scst_acg *acg) { - struct scst_acn *acn, *acnt; + struct scst_acn *acn; struct scst_acg_dev *acg_dev, *acg_dev_tmp; scst_assert_activity_suspended(); @@ -4693,8 +4692,8 @@ static void scst_del_acg(struct scst_acg *acg) acg_dev_list_entry) scst_del_acg_dev(acg_dev, true); - list_for_each_entry_safe(acn, acnt, &acg->acn_list, acn_list_entry) - scst_del_acn(acn); + list_for_each_entry(acn, &acg->acn_list, acn_list_entry) + scst_acn_sysfs_del(acn); #ifdef CONFIG_SCST_PROC list_del(&acg->acg_list_entry); @@ -5579,14 +5578,6 @@ out_free: goto out; } -/* The activity supposed to be suspended and scst_mutex held */ -static void scst_del_acn(struct scst_acn *acn) -{ - list_del(&acn->acn_list_entry); - - scst_acn_sysfs_del(acn); -} - /* The activity supposed to be suspended and scst_mutex held */ static void scst_free_acn(struct scst_acn *acn, bool reassign) { @@ -5601,7 +5592,8 @@ static void scst_free_acn(struct scst_acn *acn, bool reassign) void scst_del_free_acn(struct scst_acn *acn, bool reassign) { TRACE_ENTRY(); - scst_del_acn(acn); + list_del(&acn->acn_list_entry); + scst_acn_sysfs_del(acn); scst_free_acn(acn, reassign); TRACE_EXIT(); return;