Skip to content

Commit

Permalink
Fix spa config generate memory leak in spa_load_best function
Browse files Browse the repository at this point in the history
When spa retry load succeeds and spa recovery is requested it may
leak in spa_load_best function.  Always free the generated config
when it is not assigned to the spa.

Signed-off-by: cao.xuewen <cao.xuewen@zte.com.cn>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4940
  • Loading branch information
heary-cao authored and behlendorf committed Aug 19, 2016
1 parent 5a51708 commit ee6370a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions module/zfs/spa.c
Expand Up @@ -3095,6 +3095,8 @@ spa_load_best(spa_t *spa, spa_load_state_t state, int mosconfig,

if (config && (rewind_error || state != SPA_LOAD_RECOVER))
spa_config_set(spa, config);
else
nvlist_free(config);

if (state == SPA_LOAD_RECOVER) {
ASSERT3P(loadinfo, ==, NULL);
Expand Down

0 comments on commit ee6370a

Please sign in to comment.