Bluetooth: sco: prevent information leak in sco_conn_defer_accept()
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 25 Jun 2021 15:00:09 +0000 (18:00 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Sep 2021 09:43:00 +0000 (11:43 +0200)
[ Upstream commit 59da0b38bc2ea570ede23a3332ecb3e7574ce6b2 ]

Smatch complains that some of these struct members are not initialized
leading to a stack information disclosure:

    net/bluetooth/sco.c:778 sco_conn_defer_accept() warn:
    check that 'cp.retrans_effort' doesn't leak information

This seems like a valid warning.  I've added a default case to fix
this issue.

Fixes: 2f69a82acf6f ("Bluetooth: Use voice setting in deferred SCO connection request")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/bluetooth/sco.c

index 95fd7a837dc5c351a6d04bb1c95df3e019deacb4..3174eab6eafc9792eab6331138d48a1d44416121 100644 (file)
@@ -763,6 +763,11 @@ static void sco_conn_defer_accept(struct hci_conn *conn, u16 setting)
                        cp.max_latency = cpu_to_le16(0xffff);
                        cp.retrans_effort = 0xff;
                        break;
+               default:
+                       /* use CVSD settings as fallback */
+                       cp.max_latency = cpu_to_le16(0xffff);
+                       cp.retrans_effort = 0xff;
+                       break;
                }
 
                hci_send_cmd(hdev, HCI_OP_ACCEPT_SYNC_CONN_REQ,