libnm: don't fail assertion for _bond_get_option_normalized() with invalid bond mode

_bond_get_option_normalized() gets called with code paths that don't
assume a valid options hash. That means, the bond mode might be invalid
and we should fail an assertion.

(cherry picked from commit 1543f8a1a1)
This commit is contained in:
Thomas Haller 2020-06-30 19:31:08 +02:00
parent 45c95e9314
commit 491cd1d2cd
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -262,7 +262,11 @@ _bond_get_option_normalized (NMSettingBond* self,
mode_str = _bond_get_option_or_default (self, NM_SETTING_BOND_OPTION_MODE);
mode = _nm_setting_bond_mode_from_string (mode_str);
g_return_val_if_fail (mode != NM_BOND_MODE_UNKNOWN, NULL);
if (mode == NM_BOND_MODE_UNKNOWN) {
/* the mode is unknown, consequently, there is no normalized/default
* value either. */
return NULL;
}
if (!_nm_setting_bond_option_supported (option, mode))
return NULL;