Commit 8b976b12 authored by Joakim Andersson's avatar Joakim Andersson Committed by Johan Hedberg
Browse files

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: default avatarJoakim Andersson <joakim.andersson@nordicsemi.no>
parent e11248ba
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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;