From fdfc92c80d12655d39bc0f50f9feaaf4c9da2351 Mon Sep 17 00:00:00 2001 From: Arkadiusz Lichwa Date: Tue, 5 Jul 2016 15:55:03 +0200 Subject: [PATCH] Bluetooth: ATT: Fix ATT_CHAN() macro ATT_CHAN() macro as a wrapper to CONTAINER_OF is been used by ATT internals API wherein the main parameter is pointer to bt_l2cap_chan object. The macro returns pointer to bt_att context object but CONTAINER_OF's third parameter determines what member is taken into account in getting right address. Luckily here this third parameter "chan" of type bt_l2cap_le_chan got of its own sub-member the "chan" of type bt_l2cap_chan on first position in structure order. If such order would change somehow there could be taken wrong address. Change-Id: I955c2af11e001dac90a1eacc281ff167ceb34fb9 Signed-off-by: Arkadiusz Lichwa --- net/bluetooth/att.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/att.c b/net/bluetooth/att.c index 2a8aaa74f29..6cd0eeff0e7 100644 --- a/net/bluetooth/att.c +++ b/net/bluetooth/att.c @@ -45,7 +45,7 @@ #define BT_DBG(fmt, ...) #endif -#define ATT_CHAN(_ch) CONTAINER_OF(_ch, struct bt_att, chan) +#define ATT_CHAN(_ch) CONTAINER_OF(_ch, struct bt_att, chan.chan) #define BT_GATT_PERM_READ_MASK (BT_GATT_PERM_READ | \ BT_GATT_PERM_READ_ENCRYPT | \