option is set only if err returned from update_option() is 0, so
check err first before checking option->temporary. Otherwise, it
may results in a dereference of an undefined pointer value.
Fixes: 8180763d6f82 ("libteam: always add newly created option to option list")
Signed-off-by: Xin Long <lucien.xin(a)gmail.com>
---
libteam/options.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libteam/options.c b/libteam/options.c
index 71cc99e..51e233e 100644
--- a/libteam/options.c
+++ b/libteam/options.c
@@ -688,10 +688,10 @@ static int local_set_option_value(struct team_handle *th,
err = update_option(th, &option, opt_id, opt_type,
data, data_len, true, true);
- if (option->temporary)
- destroy_option(option);
if (err)
return err;
+ if (option->temporary)
+ destroy_option(option);
return 0;
}
--
2.27.0