From ee6370a7a48e416cbd44819d007fdaba120a328d Mon Sep 17 00:00:00 2001 From: heary-cao Date: Sat, 6 Aug 2016 15:08:51 +0800 Subject: [PATCH] Fix spa config generate memory leak in spa_load_best function 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 Signed-off-by: Brian Behlendorf Closes #4940 --- module/zfs/spa.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/module/zfs/spa.c b/module/zfs/spa.c index da238a398..3b63427c2 100644 --- a/module/zfs/spa.c +++ b/module/zfs/spa.c @@ -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);