Skip to content

nimble/host: Refactor GATT Read Multiple Variable Char Value response#2231

Open
sjanc wants to merge 1 commit into
apache:masterfrom
sjanc:gatt_read_mult
Open

nimble/host: Refactor GATT Read Multiple Variable Char Value response#2231
sjanc wants to merge 1 commit into
apache:masterfrom
sjanc:gatt_read_mult

Conversation

@sjanc
Copy link
Copy Markdown
Contributor

@sjanc sjanc commented May 12, 2026

This reworks ATT_READ_MULTIPLE_VARIABLE_RSP parsing. If response doesn't match request (number of values requested) or LV parsing shows incorrect format we ignore that and report error to app.

Comment on lines -3404 to +3416
if (attr[i].om != NULL) {
os_mbuf_free_chain(attr[i].om);
}
os_mbuf_free_chain(attr[i].om);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the mbuf allocation fails in 3384, the attr[i].om will be NULL, or the buffer is dropped in 3402. I think the check should not be removed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

os_mbuf_free_chain() handles NULL (just like free() does) on its own

ble_gattc_error(status, att_handle), &attr[0],
i,
proc->read_mult.cb_arg);
ble_gattc_error(status, att_handle), &attr[0],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The status set in 3406 (BLE_HS_EBADDATA) is passed to ble_gattc_error() function which is bad IMO.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe not. The ble_gattc_error() function name seems to be misleading.

Comment thread nimble/host/src/ble_gattc.c
@sjanc sjanc force-pushed the gatt_read_mult branch 2 times, most recently from 7131f1b to 053c57b Compare May 12, 2026 09:48
Comment thread nimble/host/src/ble_gattc.c Outdated
/* failed to correctly parse response,
* cleanup any partial data and set status if not set already
*/
if (i != proc->read_mult.num_handles || OS_MBUF_PKTLEN(*om) != 0) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: i < proc->read_mult.num_handles

This reworks ATT_READ_MULTIPLE_VARIABLE_RSP parsing. If response
doesn't match request (number of values requested) or LV parsing
shows incorrect format we ignore that and report error to app.
@sjanc sjanc force-pushed the gatt_read_mult branch from 053c57b to a771a90 Compare May 13, 2026 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants