diff options
author | Xin Long <lucien.xin@gmail.com> | 2021-11-24 12:04:54 -0500 |
---|---|---|
committer | Jiri Pirko <jiri@nvidia.com> | 2022-06-27 17:49:46 +0200 |
commit | 1569cf8ac96294083ed0031ef5b4174489cd9472 (patch) | |
tree | 0d4683a66eed6e9ad5aa1a8b179c93db62b02f12 | |
parent | 69a7494bb77dc10bb27076add07b380dbd778592 (diff) | |
download | libteam-1569cf8ac96294083ed0031ef5b4174489cd9472.tar.gz |
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>
-rw-r--r-- | libteam/options.c | 4 |
1 files 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; } |