linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: L2CAP: Fix errors during L2CAP_CREDIT_BASED_CONNECTION_REQ (0x17)
@ 2020-05-04 16:01 CEE Forostyan, Konstantin
  2020-05-05 23:34 ` Marcel Holtmann
  0 siblings, 1 reply; 4+ messages in thread
From: CEE Forostyan, Konstantin @ 2020-05-04 16:01 UTC (permalink / raw)
  To: linux-bluetooth, Luiz Augusto von Dentz

From: Konstantin Forostyan <konstantin.forostyan@peiker-cee.de>

Fix 2 typos in L2CAP_CREDIT_BASED_CONNECTION_REQ (0x17) handling function, that
cause BlueZ answer with L2CAP_CR_LE_INVALID_PARAMS or L2CAP_CR_LE_INVALID_SCID
error on a correct ECRED connection request.

Enchanced Credit Based Mode support was recently introduced with the commit
15f02b91056253e8cdc592888f431da0731337b8 ("Bluetooth: L2CAP: Add initial code
for Enhanced Credit Based Mode").

Signed-off-by: Konstantin Forostyan <konstantin.forostyan@peiker-cee.de>
---

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index fd9d0d08f9c9..fe913a5c754a 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -5927,7 +5927,7 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn,
 	if (!enable_ecred)
 		return -EINVAL;
 
-	if (cmd_len < sizeof(*req) || cmd_len - sizeof(*req) % sizeof(u16)) {
+	if (cmd_len < sizeof(*req) || (cmd_len - sizeof(*req)) % sizeof(u16)) {
 		result = L2CAP_CR_LE_INVALID_PARAMS;
 		goto response;
 	}
@@ -5964,7 +5964,7 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn,
 	}
 
 	result = L2CAP_CR_LE_SUCCESS;
-	cmd_len -= sizeof(req);
+	cmd_len -= sizeof(*req);
 	num_scid = cmd_len / sizeof(u16);
 
 	for (i = 0; i < num_scid; i++) {

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Bluetooth: L2CAP: Fix errors during L2CAP_CREDIT_BASED_CONNECTION_REQ (0x17)
  2020-05-04 16:01 [PATCH] Bluetooth: L2CAP: Fix errors during L2CAP_CREDIT_BASED_CONNECTION_REQ (0x17) CEE Forostyan, Konstantin
@ 2020-05-05 23:34 ` Marcel Holtmann
  0 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2020-05-05 23:34 UTC (permalink / raw)
  To: CEE Forostyan, Konstantin; +Cc: linux-bluetooth, Luiz Augusto von Dentz

Hi Konstantin,

> Fix 2 typos in L2CAP_CREDIT_BASED_CONNECTION_REQ (0x17) handling function, that
> cause BlueZ answer with L2CAP_CR_LE_INVALID_PARAMS or L2CAP_CR_LE_INVALID_SCID
> error on a correct ECRED connection request.
> 
> Enchanced Credit Based Mode support was recently introduced with the commit
> 15f02b91056253e8cdc592888f431da0731337b8 ("Bluetooth: L2CAP: Add initial code
> for Enhanced Credit Based Mode").
> 
> Signed-off-by: Konstantin Forostyan <konstantin.forostyan@peiker-cee.de>
> ---

patch has been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Bluetooth: L2CAP: Fix errors during L2CAP_CREDIT_BASED_CONNECTION_REQ (0x17)
  2020-04-29 16:48     ` [PATCH] Bluetooth: L2CAP: Fix errors during L2CAP_CREDIT_BASED_CONNECTION_REQ (0x17) CEE Forostyan, Konstantin
@ 2020-04-29 17:17       ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2020-04-29 17:17 UTC (permalink / raw)
  To: CEE Forostyan, Konstantin; +Cc: linux-bluetooth

Hi Konstantin,

On Wed, Apr 29, 2020 at 9:52 AM CEE Forostyan, Konstantin
<Konstantin.Forostyan@peiker-cee.de> wrote:
>
> Hi All,
>
> During Bluetooth qualification tests I found out that Bluetooth stack responds with an error to a correct L2CAP_CREDIT_BASED_CONNECTION_REQ. Please review the 2 bugfixes I made in kernel in order to correct this problem.
>
> Best regards
> Konstantin
>
>
> --- a/net/bluetooth/l2cap_core.c        2020-04-28 18:19:10.481887583 +0200
> +++ b/net/bluetooth/l2cap_core.c        2020-04-28 18:21:41.000000000 +0200
> @@ -5817,7 +5817,7 @@
>         if (!enable_ecred)
>                 return -EINVAL;
>
> -       if (cmd_len < sizeof(*req) || cmd_len - sizeof(*req) % sizeof(u16)) {
> +       if (cmd_len < sizeof(*req) || (cmd_len - sizeof(*req)) % sizeof(u16)) {
>                 result = L2CAP_CR_LE_INVALID_PARAMS;
>                 goto response;
>         }
> @@ -5855,7 +5855,7 @@
>         }
>
>         result = L2CAP_CR_LE_SUCCESS;
> -       cmd_len -= sizeof(req);
> +       cmd_len -= sizeof(*req);
>         num_scid = cmd_len / sizeof(u16);
>
>         for (i = 0; i < num_scid; i++) {

Weird that I didn't run into this when creating the test for
l2cap-tester, they look correct though so please send them as proper
patches so we can apply to bluetooth-next, also please ensure
l2cap-tester is working.

-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] Bluetooth: L2CAP: Fix errors during L2CAP_CREDIT_BASED_CONNECTION_REQ (0x17)
  2020-04-21 12:56   ` AW: " CEE Forostyan, Konstantin
@ 2020-04-29 16:48     ` CEE Forostyan, Konstantin
  2020-04-29 17:17       ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 4+ messages in thread
From: CEE Forostyan, Konstantin @ 2020-04-29 16:48 UTC (permalink / raw)
  To: linux-bluetooth

Hi All,

During Bluetooth qualification tests I found out that Bluetooth stack responds with an error to a correct L2CAP_CREDIT_BASED_CONNECTION_REQ. Please review the 2 bugfixes I made in kernel in order to correct this problem.

Best regards
Konstantin


--- a/net/bluetooth/l2cap_core.c	2020-04-28 18:19:10.481887583 +0200
+++ b/net/bluetooth/l2cap_core.c	2020-04-28 18:21:41.000000000 +0200
@@ -5817,7 +5817,7 @@
 	if (!enable_ecred)
 		return -EINVAL;
 
-	if (cmd_len < sizeof(*req) || cmd_len - sizeof(*req) % sizeof(u16)) {
+	if (cmd_len < sizeof(*req) || (cmd_len - sizeof(*req)) % sizeof(u16)) {
 		result = L2CAP_CR_LE_INVALID_PARAMS;
 		goto response;
 	}
@@ -5855,7 +5855,7 @@
 	}
 
 	result = L2CAP_CR_LE_SUCCESS;
-	cmd_len -= sizeof(req);
+	cmd_len -= sizeof(*req);
 	num_scid = cmd_len / sizeof(u16);
 
 	for (i = 0; i < num_scid; i++) {

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-05-05 23:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-04 16:01 [PATCH] Bluetooth: L2CAP: Fix errors during L2CAP_CREDIT_BASED_CONNECTION_REQ (0x17) CEE Forostyan, Konstantin
2020-05-05 23:34 ` Marcel Holtmann
  -- strict thread matches above, loose matches on Subject: below --
2020-04-21 10:45 How to to get L2CAP Enhanced Credit Based Mode working? CEE Forostyan, Konstantin
2020-04-21 12:42 ` Ryll, Jan (GED-SDD2)
2020-04-21 12:56   ` AW: " CEE Forostyan, Konstantin
2020-04-29 16:48     ` [PATCH] Bluetooth: L2CAP: Fix errors during L2CAP_CREDIT_BASED_CONNECTION_REQ (0x17) CEE Forostyan, Konstantin
2020-04-29 17:17       ` Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).