Skip to content

Bluetooth: SDP: Fix issue that RX buf is used for others discovery #94552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lylezhu2012
Copy link
Contributor

In current implementation, the received buffer is incorrectly used for other SDP discover requests.

Release the RX buffer when the SDP discovery is done. And allocate the new RX buffer from the pool of the new SDP discovery request.

In current implementation, the received buffer is incorrectly used for
other SDP discover requests.

Release the RX buffer when the SDP discovery is done. And allocate the
new RX buffer from the pool of the new SDP discovery request.

Signed-off-by: Lyle Zhu <[email protected]>
Copy link

@@ -1705,6 +1705,10 @@ static void sdp_client_params_iterator(struct bt_sdp_client *session)
sys_slist_remove(&session->reqs, NULL, &param->_node);
/* Invalidate cached param in context */
session->param = NULL;
if (session->rec_buf != NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

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

current session rec_buf would be alloc when sdp_client_connected. if do alloc rec_buf when user request every discovery. then rec_buf maybe need to delete within sdp_client_connected.

However I am some doubts.
recv_len would be reset when discovery finished. why rec_buf would be some garbage data?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do not get your point.

As my comments said, the received buffer is incorrectly used for other SDP discover requests.

This is why this change created.

@chengkai15
Copy link
Contributor

In current implementation, the received buffer is incorrectly used for other SDP discover requests.

Release the RX buffer when the SDP discovery is done. And allocate the new RX buffer from the pool of the new SDP discovery request.

hi, @lylezhu2012 Thanks for your explanation.

rec_buf would be allocated when connected, and free when disconncted. could we reset rec_buf value, and do not free rec_buf ?

static void sdp_client_connected(struct bt_l2cap_chan *chan)
{
	struct bt_sdp_client *session = SDP_CLIENT_CHAN(chan);

	LOG_DBG("session %p chan %p connected", session, chan);

	k_sem_take(&session->sem_lock, K_FOREVER);
	**session->rec_buf = chan->ops->alloc_buf(chan);**

@lylezhu2012
Copy link
Contributor Author

rec_buf would be allocated when connected, and free when disconncted. could we reset rec_buf value, and do not free rec_buf ?

The session->rec_buf cannot not be used by other request. It should be released when the request (session->param) is removed from request queue.

@@ -1912,7 +1916,11 @@ static int sdp_client_discover(struct bt_sdp_client *session)
param = session->param;
}

if (!param) {
if (param != NULL && session->rec_buf == NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The session->rec_buf should be NULL here, add assert or LOG_ERR here? Or If it is not NULL, release it here?

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.

4 participants