options: move option temporary check after the err check

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@gmail.com>
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
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 @@
 
 	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;
 }