Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3624976pxb; Mon, 24 Jan 2022 13:48:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJyxWWK6UWELQ++t/KUgdU9/W9Kd36GvVKeD9LOjxJ491RMypcqMly+0J393XPEeYN5VNpI7 X-Received: by 2002:a17:90a:f0ce:: with SMTP id fa14mr265188pjb.212.1643060785944; Mon, 24 Jan 2022 13:46:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643060785; cv=none; d=google.com; s=arc-20160816; b=NGfcjWXigHBniGoExLWtqzY/c4bjCy3hFHR85YhSazM7IwbuOe2p3Qz9ndAoH6DJ4j WGETJ+w5+YOi6tbjFe7zJQr3naJcWUdXs3UYz1yF7OEnBps2cwGTQl2ZC714hWBz5Oyy tkvKqxTkxn7Vdxt+wYXhkhiQxtGz/DYj+ytJC43w4kYraLoDHkgqesrNhvMMLcuyOasr tEeYmW3aU58Cj1tIB95cxOhKhVhZAC/sm36Lk2sskx+fNGRO/OjiF04mj2YE6uJRRpQs XKgXLuXJ3AwrQxnDy/gnyQqgMSROhljftIciUejcmPdS7LAqoTR3AOu92uoF9AIlu6dl Z4iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=p/cZIX2GC8VzbtFPwrl5tfzlsaT/jPbJPvVIWBhQHQk=; b=RQehpVuUHkCRI/lF6Nss3z/+KPSIPTPG63MDSFupEaplWplDkq6cnk9gTgrGyhuMtO pvH2Of9meQU9JgEcmBe6eCim4+TWby4YqTtz6cvsaZt9iYomiwKGq36xZxK1vUJ42nz0 BnrkW2l1gcEy6viV+QrY2L71zm3XkVFUxpFKP8mJT8dHN0tfrCs5a87UBM7YhAKE88ra DFHiLQUwVkbd0SGkNMJlDXTiqpNMT7prjgt4dXQExHjO5e+j6+H7Qv9/8BgsTTeppOny P2qlkyU5EXpIqodvnkeC9K/OYr3gmJJ2TNuAM5/w7yRc/URqroePmO7q6YeJmz338rL/ VajQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aGhRZg4H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ml7si429249pjb.127.2022.01.24.13.46.13; Mon, 24 Jan 2022 13:46:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aGhRZg4H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1452347AbiAXVZP (ORCPT + 99 others); Mon, 24 Jan 2022 16:25:15 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:52752 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443929AbiAXU7h (ORCPT ); Mon, 24 Jan 2022 15:59:37 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A80776131F; Mon, 24 Jan 2022 20:59:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BAA1C340E5; Mon, 24 Jan 2022 20:59:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057975; bh=fvSo4k2DvJm5t6/jjMZlDtic3DNw8fsnPxhjZI0j8sk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aGhRZg4HifZEzRNNdokwj7TVtnkmiltIyfk4hRqMNOgS89CRi9x86+dKsjSiqYHM0 a4kak+wCK5wt+gHUxpdS5RAlcPjFAtCbYiwUR68da1MlxcJyVrngZJpGB+9UphcM/X 0AQu9UDf13vj29V8Ef3L3iYkdas97ewGfeGIBjRY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marcel Holtmann , Jackie Liu , Sasha Levin Subject: [PATCH 5.16 0140/1039] Bluetooth: fix uninitialized variables notify_evt Date: Mon, 24 Jan 2022 19:32:09 +0100 Message-Id: <20220124184129.882767912@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jackie Liu [ Upstream commit a27c519a816437ec92f0ffa3adbc168c2c08725b ] Coverity Scan report: [...] *** CID 1493985: Uninitialized variables (UNINIT) /net/bluetooth/hci_event.c: 4535 in hci_sync_conn_complete_evt() 4529 4530 /* Notify only in case of SCO over HCI transport data path which 4531 * is zero and non-zero value shall be non-HCI transport data path 4532 */ 4533 if (conn->codec.data_path == 0) { 4534 if (hdev->notify) >>> CID 1493985: Uninitialized variables (UNINIT) >>> Using uninitialized value "notify_evt" when calling "*hdev->notify". 4535 hdev->notify(hdev, notify_evt); 4536 } 4537 4538 hci_connect_cfm(conn, ev->status); 4539 if (ev->status) 4540 hci_conn_del(conn); [...] Although only btusb uses air_mode, and he only handles HCI_NOTIFY_ENABLE_SCO_CVSD and HCI_NOTIFY_ENABLE_SCO_TRANSP, there is still a very small chance that ev->air_mode is not equal to 0x2 and 0x3, but notify_evt is initialized to HCI_NOTIFY_ENABLE_SCO_CVSD or HCI_NOTIFY_ENABLE_SCO_TRANSP. the context is maybe not correct. Let us directly use the required function instead of re-initializing it, so as to restore the original logic and make the code more correct. Addresses-Coverity: ("Uninitialized variables") Fixes: f4f9fa0c07bb ("Bluetooth: Allow usb to auto-suspend when SCO use non-HCI transport") Suggested-by: Marcel Holtmann Signed-off-by: Jackie Liu Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin --- net/bluetooth/hci_event.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 59f0691d907f6..6eba439487749 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -4445,7 +4445,6 @@ static void hci_sync_conn_complete_evt(struct hci_dev *hdev, { struct hci_ev_sync_conn_complete *ev = (void *) skb->data; struct hci_conn *conn; - unsigned int notify_evt; BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); @@ -4517,22 +4516,18 @@ static void hci_sync_conn_complete_evt(struct hci_dev *hdev, } bt_dev_dbg(hdev, "SCO connected with air mode: %02x", ev->air_mode); - - switch (ev->air_mode) { - case 0x02: - notify_evt = HCI_NOTIFY_ENABLE_SCO_CVSD; - break; - case 0x03: - notify_evt = HCI_NOTIFY_ENABLE_SCO_TRANSP; - break; - } - /* Notify only in case of SCO over HCI transport data path which * is zero and non-zero value shall be non-HCI transport data path */ - if (conn->codec.data_path == 0) { - if (hdev->notify) - hdev->notify(hdev, notify_evt); + if (conn->codec.data_path == 0 && hdev->notify) { + switch (ev->air_mode) { + case 0x02: + hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD); + break; + case 0x03: + hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_TRANSP); + break; + } } hci_connect_cfm(conn, ev->status); -- 2.34.1