Bluetooth: GATT: Provide correct error code when disconnected

Calling indicate or notify on a disconnected connection object would
result in the error code ENOMEM when failing to acquire buffers instead
of the expected return code ENOTCONN.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
Joakim Andersson 2019-09-27 13:26:32 +02:00 committed by Johan Hedberg
commit 8b976b12a8

View file

@ -1586,6 +1586,10 @@ int bt_gatt_notify_cb(struct bt_conn *conn,
attr = params->attr;
if (conn && conn->state != BT_CONN_CONNECTED) {
return -ENOTCONN;
}
handle = attr->handle ? : find_static_attr(attr);
if (!handle) {
return -ENOENT;
@ -1644,6 +1648,10 @@ int bt_gatt_indicate(struct bt_conn *conn,
attr = params->attr;
if (conn && conn->state != BT_CONN_CONNECTED) {
return -ENOTCONN;
}
handle = attr->handle ? : find_static_attr(attr);
if (!handle) {
return -ENOENT;