Skip to content

Commit f1a2295

Browse files
Qbicznashif
authored andcommitted
Bluetooth: settings: Always initialize key when storing Client Features
Fixes #13572. Initialize key used to store Client Features even when config was not found. Signed-off-by: Filip Kubicz <[email protected]>
1 parent 18f9db5 commit f1a2295

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

subsys/bluetooth/host/gatt.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2856,27 +2856,28 @@ static int bt_gatt_store_cf(struct bt_conn *conn)
28562856

28572857
cfg = find_cf_cfg(conn);
28582858
if (!cfg) {
2859-
/* No cfg found just cleare it */
2859+
/* No cfg found, just clear it */
2860+
BT_DBG("No config for CF");
28602861
str = NULL;
28612862
len = 0;
2862-
goto save;
2863-
}
2863+
} else {
2864+
str = (char *)cfg->data;
2865+
len = sizeof(cfg->data);
28642866

2865-
if (conn->id) {
2866-
char id_str[4];
2867+
if (conn->id) {
2868+
char id_str[4];
28672869

2868-
snprintk(id_str, sizeof(id_str), "%u", conn->id);
2869-
bt_settings_encode_key(key, sizeof(key), "cf",
2870-
&conn->le.dst, id_str);
2871-
} else {
2870+
snprintk(id_str, sizeof(id_str), "%u", conn->id);
2871+
bt_settings_encode_key(key, sizeof(key), "cf",
2872+
&conn->le.dst, id_str);
2873+
}
2874+
}
2875+
2876+
if (!cfg || !conn->id) {
28722877
bt_settings_encode_key(key, sizeof(key), "cf",
28732878
&conn->le.dst, NULL);
28742879
}
28752880

2876-
str = (char *)cfg->data;
2877-
len = sizeof(cfg->data);
2878-
2879-
save:
28802881
err = settings_save_one(key, str, len);
28812882
if (err) {
28822883
BT_ERR("Failed to store Client Features (err %d)", err);

0 commit comments

Comments
 (0)