-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1705,6 +1705,10 @@ static void sdp_client_params_iterator(struct bt_sdp_client *session) | |
sys_slist_remove(&session->reqs, NULL, ¶m->_node); | ||
/* Invalidate cached param in context */ | ||
session->param = NULL; | ||
if (session->rec_buf != NULL) { | ||
net_buf_unref(session->rec_buf); | ||
session->rec_buf = NULL; | ||
} | ||
/* Reset continuation state in current context */ | ||
(void)memset(&session->cstate, 0, sizeof(session->cstate)); | ||
/* Clear total length */ | ||
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The change point is,
So at line 1919, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we move all the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For most cases, I think only one request will be performed in the SDP connection session. So I think it is reasonable to allocate the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO, moving the Using the same way and putting the same place make the code to be more easy to maintain. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well. But it is not this PR purpose. Over-fixing is not a good idea. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agree, another pr is needed. |
||
session->rec_buf = net_buf_alloc(param->pool, K_FOREVER); | ||
} | ||
|
||
if (param == NULL || session->rec_buf == NULL) { | ||
struct bt_l2cap_chan *chan = &session->chan.chan; | ||
|
||
session->state = SDP_CLIENT_DISCONNECTING; | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.