Skip to content

Commit

Permalink
tipc: Fix log buffer memory leak if initialization fails
Browse files Browse the repository at this point in the history
Moves log buffer cleanup into tipc_core_stop() so that memory allocated
for the log buffer is freed if tipc_core_start() is unsuccessful.

Signed-off-by: Anders Kaseorg <[email protected]>
Signed-off-by: Allan Stephens <[email protected]>
Signed-off-by: Paul Gortmaker <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Anders Kaseorg authored and davem330 committed Aug 18, 2010
1 parent 24763d8 commit f813809
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions net/tipc/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ void tipc_core_stop(void)
tipc_nametbl_stop();
tipc_ref_table_stop();
tipc_socket_stop();
tipc_log_resize(0);
}

/**
Expand Down Expand Up @@ -203,7 +204,9 @@ static int __init tipc_init(void)
{
int res;

tipc_log_resize(CONFIG_TIPC_LOG);
if (tipc_log_resize(CONFIG_TIPC_LOG) != 0)
warn("Unable to create log buffer\n");

info("Activated (version " TIPC_MOD_VER
" compiled " __DATE__ " " __TIME__ ")\n");

Expand All @@ -230,7 +233,6 @@ static void __exit tipc_exit(void)
tipc_core_stop_net();
tipc_core_stop();
info("Deactivated\n");
tipc_log_resize(0);
}

module_init(tipc_init);
Expand Down

0 comments on commit f813809

Please sign in to comment.