Commit e84d76f9 authored by Mariusz Skamra's avatar Mariusz Skamra Committed by Fabio Baltieri
Browse files

Bluetooth: audio: vocs: Fix missing instance type checks



The VOCS API uses `bt_vocs` object to reference both client and server
instance. This adds missing instance type checks to avoid invalid API
usage.

Signed-off-by: default avatarMariusz Skamra <mariusz.skamra@codecoup.pl>
parent 18dfcbc2
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -287,6 +287,11 @@ void *bt_vocs_svc_decl_get(struct bt_vocs *vocs)
		return NULL;
	}

	CHECKIF(vocs->client_instance) {
		LOG_DBG("vocs pointer shall be server instance");
		return NULL;
	}

	return vocs->srv.service_p->attrs;
}

@@ -310,6 +315,11 @@ int bt_vocs_register(struct bt_vocs *vocs,
		return -EINVAL;
	}

	CHECKIF(vocs->client_instance) {
		LOG_DBG("vocs pointer shall be server instance");
		return -EINVAL;
	}

	CHECKIF(!param) {
		LOG_DBG("NULL params pointer");
		return -EINVAL;
+10 −0
Original line number Diff line number Diff line
@@ -716,6 +716,11 @@ int bt_vocs_discover(struct bt_conn *conn, struct bt_vocs *inst,
		return -EINVAL;
	}

	CHECKIF(!inst->client_instance) {
		LOG_DBG("vocs pointer shall be client instance");
		return -EINVAL;
	}

	CHECKIF(param->end_handle < param->start_handle) {
		LOG_DBG("start_handle (%u) shall be less than end_handle (%u)", param->start_handle,
			param->end_handle);
@@ -757,5 +762,10 @@ void bt_vocs_client_cb_register(struct bt_vocs *inst, struct bt_vocs_cb *cb)
		return;
	}

	CHECKIF(!inst->client_instance) {
		LOG_DBG("vocs pointer shall be client instance");
		return;
	}

	inst->cli.cb = cb;
}