Both in iscsiadm and iscsistart, a list is initialized to management struct iscsi_param which allocated by idbm_alloc_user_param(). While both of iscsiadm and iscsistart did not free these iscsi_param when process exit, this patch add a free flow when process exit.
Signed-off-by: Wenchao Hao <haowenc...@huawei.com> Signed-off-by: Zhiqiang Liu <liuzhiqian...@huawei.com> Signed-off-by: Wu Bo <wub...@huawei.com> --- usr/idbm.c | 14 ++++++++++++++ usr/idbm.h | 1 + usr/iscsiadm.c | 4 ++++ usr/iscsistart.c | 5 +++++ 4 files changed, 24 insertions(+) diff --git a/usr/idbm.c b/usr/idbm.c index 42c2699..f8b50f1 100644 --- a/usr/idbm.c +++ b/usr/idbm.c @@ -2903,6 +2903,20 @@ free_param: return NULL; } +void idbm_free_user_param(struct user_param *param) +{ + if (!param) + return; + + if (param->name) + free(param->name); + + if (param->value) + free(param->value); + + free(param); +} + int idbm_node_set_rec_from_param(struct list_head *params, node_rec_t *rec, int verify) { diff --git a/usr/idbm.h b/usr/idbm.h index 46cd82a..7496f1d 100644 --- a/usr/idbm.h +++ b/usr/idbm.h @@ -153,6 +153,7 @@ extern int idbm_node_set_rec_from_param(struct list_head *params, extern int idbm_node_set_param(void *data, node_rec_t *rec); extern int idbm_discovery_set_param(void *data, discovery_rec_t *rec); struct user_param *idbm_alloc_user_param(char *name, char *value); +void idbm_free_user_param(struct user_param *param); extern void idbm_node_setup_defaults(node_rec_t *rec); extern struct node_rec *idbm_find_rec_in_list(struct list_head *rec_list, char *targetname, char *addr, diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c index 667f83c..ea1643b 100644 --- a/usr/iscsiadm.c +++ b/usr/iscsiadm.c @@ -4075,6 +4075,10 @@ free_ifaces: list_del(&iface->list); free(iface); } + list_for_each_entry(param, ¶ms, list) { + list_del(¶m->list); + idbm_free_user_param(param); + } free_transports(); sysfs_cleanup(); return rc; diff --git a/usr/iscsistart.c b/usr/iscsistart.c index ee810f7..73991b3 100644 --- a/usr/iscsistart.c +++ b/usr/iscsistart.c @@ -347,6 +347,7 @@ int main(int argc, char *argv[]) struct boot_context *context, boot_context; struct sigaction sa_old; struct sigaction sa_new; + struct user_param *param; int control_fd, mgmt_ipc_fd, err; pid_t pid; @@ -541,6 +542,10 @@ int main(int argc, char *argv[]) mgmt_ipc_close(mgmt_ipc_fd); free_initiator(); sysfs_cleanup(); + list_for_each_entry(param, &user_params, list) { + list_del(¶m->list); + idbm_free_user_param(param); + } log_debug(1, "iscsi child done"); return 0; -- 2.27.0 -- You received this message because you are subscribed to the Google Groups "open-iscsi" group. To unsubscribe from this group and stop receiving emails from it, send an email to open-iscsi+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/open-iscsi/20201207015410.48488-8-haowenchao%40huawei.com.