diff mbox series

[BlueZ,v1,2/2] a2dp: Reject connection when the channel limit is exceeded

Message ID 20240129204154.95773-3-VAnPushkarev@salutedevices.com (mailing list archive)
State New, archived
Headers show
Series Introduce option to limit A2DP channels | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch warning WARNING:LONG_LINE: line length of 90 exceeds 80 columns #118: FILE: profiles/audio/a2dp.c:2553: + queue_length(server->channels) > btd_opts.a2dp.channels) { WARNING:LONG_LINE_STRING: line length of 81 exceeds 80 columns #120: FILE: profiles/audio/a2dp.c:2555: + DBG("Reject current connection, A2DP channel limit exceeded: %d", /github/workspace/src/src/13536360.patch total: 0 errors, 2 warnings, 14 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. /github/workspace/src/src/13536360.patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS.
tedd_an/GitLint success Gitlint PASS
tedd_an/IncrementalBuild success Incremental Build PASS

Commit Message

Victor Pushkarev Jan. 29, 2024, 8:41 p.m. UTC
Reject incoming connection when the configured limit
for A2DP channels is exceeded.

Signed-off-by: Victor Pushkarev <VAnPushkarev@salutedevices.com>
---
 profiles/audio/a2dp.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Luiz Augusto von Dentz Jan. 29, 2024, 9:06 p.m. UTC | #1
Hi,

On Mon, Jan 29, 2024 at 3:42 PM Victor Pushkarev
<VAnPushkarev@salutedevices.com> wrote:
>
> Reject incoming connection when the configured limit
> for A2DP channels is exceeded.
>
> Signed-off-by: Victor Pushkarev <VAnPushkarev@salutedevices.com>
> ---
>  profiles/audio/a2dp.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
> index b43161a13..117b27db3 100644
> --- a/profiles/audio/a2dp.c
> +++ b/profiles/audio/a2dp.c
> @@ -2549,6 +2549,14 @@ static void confirm_cb(GIOChannel *io, gpointer data)
>         if (!chan)
>                 goto drop;
>
> +       if (btd_opts.a2dp.channels &&
> +                               queue_length(server->channels) > btd_opts.a2dp.channels) {
> +               device_request_disconnect(device, NULL);
> +               DBG("Reject current connection, A2DP channel limit exceeded: %d",
> +                                               btd_opts.a2dp.channels);
> +               goto drop;
> +       }

NAK, this is the wrong layer to do this, it is up to the MediaEndpoint
implementation to tell how many streams it can handle.

>         chan->auth_id = btd_request_authorization(&src, &dst,
>                                                         ADVANCED_AUDIO_UUID,
>                                                         auth_cb, chan);
> --
> 2.39.3 (Apple Git-145)
>
>
diff mbox series

Patch

diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index b43161a13..117b27db3 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
@@ -2549,6 +2549,14 @@  static void confirm_cb(GIOChannel *io, gpointer data)
 	if (!chan)
 		goto drop;
 
+	if (btd_opts.a2dp.channels &&
+				queue_length(server->channels) > btd_opts.a2dp.channels) {
+		device_request_disconnect(device, NULL);
+		DBG("Reject current connection, A2DP channel limit exceeded: %d",
+						btd_opts.a2dp.channels);
+		goto drop;
+	}
+
 	chan->auth_id = btd_request_authorization(&src, &dst,
 							ADVANCED_AUDIO_UUID,
 							auth_cb, chan);