[v1,1/1] Bluetooth: MGMT: Use correct address for memcpy()

Message ID 20230717093214.82102-1-andriy.shevchenko@linux.intel.com
State New
Headers
Series [v1,1/1] Bluetooth: MGMT: Use correct address for memcpy() |

Commit Message

Andy Shevchenko July 17, 2023, 9:32 a.m. UTC
  In function ‘fortify_memcpy_chk’,
    inlined from ‘get_conn_info_complete’ at net/bluetooth/mgmt.c:7281:2:
include/linux/fortify-string.h:592:25: error: call to ‘__read_overflow2_field’ declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Werror=attribute-warning]
  592 |                         __read_overflow2_field(q_size_field, size);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

This is due to the wrong member is used for memcpy(). Use correct one.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 net/bluetooth/mgmt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

patchwork-bot+bluetooth@kernel.org July 17, 2023, 8 p.m. UTC | #1
Hello:

This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Mon, 17 Jul 2023 12:32:14 +0300 you wrote:
> In function ‘fortify_memcpy_chk’,
>     inlined from ‘get_conn_info_complete’ at net/bluetooth/mgmt.c:7281:2:
> include/linux/fortify-string.h:592:25: error: call to ‘__read_overflow2_field’ declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Werror=attribute-warning]
>   592 |                         __read_overflow2_field(q_size_field, size);
>       |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
> 
> [...]

Here is the summary with links:
  - [v1,1/1] Bluetooth: MGMT: Use correct address for memcpy()
    https://git.kernel.org/bluetooth/bluetooth-next/c/75401514ef1b

You are awesome, thank you!
  

Patch

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 33c06f7c7641..d6c9b7bc8592 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -7278,7 +7278,7 @@  static void get_conn_info_complete(struct hci_dev *hdev, void *data, int err)
 
 	bt_dev_dbg(hdev, "err %d", err);
 
-	memcpy(&rp.addr, &cp->addr.bdaddr, sizeof(rp.addr));
+	memcpy(&rp.addr, &cp->addr, sizeof(rp.addr));
 
 	status = mgmt_status(err);
 	if (status == MGMT_STATUS_SUCCESS) {