Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1049636ybf; Fri, 28 Feb 2020 12:57:32 -0800 (PST) X-Google-Smtp-Source: APXvYqwvyOae4pEzOBAVFEFxmFnxTP57Jqnl1tBKJ6qMAYsuTnEO6oskanaXjCewgIVVzsqjvRG7 X-Received: by 2002:a9d:1c1:: with SMTP id e59mr4396318ote.150.1582923452497; Fri, 28 Feb 2020 12:57:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582923452; cv=none; d=google.com; s=arc-20160816; b=SRZ8CQKz3WL6CHo+TZfQ1oAPohyIA6lSX/Pr0Z+nNuF7RKF8DdeE+KkAq34OMrTUyf 7c/jcqKfznRo7VZOfMofTz7G2WRnY2aUCa4ohTn/d3J027eJex01CGZ4U78aBBl/aypI M0+YKFP/XU1PaNhgzHgtSLWrgCTyw/evn3EIuK7BFgSnsLK0o2/a0ZUyMaGsriPHbSFN cQNHzyAkhsPb7zK+wLWQzInFMig5DLhbMpDXjXT96EQ24x0kX2FT7SSAcck+k2djkGSB 6/u2Si0FpaeF/nfcqQB54WmW66CQUNdjKTz0hPhoJPDuP/QQjK2yGsqkafSckrEk0BTg 6yTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=pFJTaE2xrNcAanqHyoHceUjLy2NQv7Ru7eflVQr0amA=; b=Z95C4D1YT98EZxPiaNtTQzFiKHlfvj0lUTCW/3wm2b9ooLkYDR2Lqr6UW2eVOELahE Jvd/QMCcpmvPdutNuN/qQygWEBD+JEOZsSMdnSVccMMbv7608eiBy6q6WJV9+ASptdMr Rv6gm2mUp6ZTrZ4XJ5BMZGrnM/1q8aBxnmTbrhY7sKxaN8KaiGcjx7GZIFSypFVTtHAJ ZMcLJKu3m3ljF/P0OwLvYqba9C2v94aCDHqeD61+sGrkb0nNKLcpOGerO3NsmVCAQjMh F8ELXx9T6mVQ4l/NipkSExQIbjibJX4LyEN7qf6fHiTxOKlEzI5yZJ4z891jsABAWnby IgTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TOB9UA49; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x20si501925otq.253.2020.02.28.12.56.39; Fri, 28 Feb 2020 12:57:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TOB9UA49; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726621AbgB1Uvw (ORCPT + 99 others); Fri, 28 Feb 2020 15:51:52 -0500 Received: from mail-vs1-f65.google.com ([209.85.217.65]:35076 "EHLO mail-vs1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725805AbgB1Uvw (ORCPT ); Fri, 28 Feb 2020 15:51:52 -0500 Received: by mail-vs1-f65.google.com with SMTP id u26so2846663vsg.2 for ; Fri, 28 Feb 2020 12:51:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pFJTaE2xrNcAanqHyoHceUjLy2NQv7Ru7eflVQr0amA=; b=TOB9UA49RZk66S1xgAVImJjLgvIY7LOObSCwDyLgbLZkjptYvFJA+gE2dzPoR1qEfd TwrPnKNnQokZ2YlLCQbAu+uCUh8JIEMRCHWLg+qSVaIeovpZYwyyGzbgjirbr6nCs4y6 +g4XnmcLhUWsZEqwtDMMdl31vizWkpFBHV46Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pFJTaE2xrNcAanqHyoHceUjLy2NQv7Ru7eflVQr0amA=; b=oO+Y9TKO5jjOjhtcE7ulyecJWZp37byzM/ARhsafx1n4aX1pZjcjGSDv5TS9pf/TXF UT+YqcND0x/BAJyKS507FQT3PG8JR4Ea+dUINSqXa9ZQK9inwe+MojkYp9LV4v1rLVxs vZ+TPA0QcdeL3nyy+7kpHESbYe4uznR14+Uwjf4NYlACV5/0meeCMfMQS1vErS+rdP1z WjtoEhgAY0qetrui4w7LRHYLRG6wYFq9qOY2zo3GNZOfyezjt48yAQo57MpDeO5K1BSY f0IveisMGuIRIOnk1oD09dVOHNfsvgrKB/DXOWMDB3DLcUKFBLi2dzB2I9gpwnT8Cwm7 pNcg== X-Gm-Message-State: ANhLgQ22ux+IahjBryl84WRHT5Ep03WDP6PjpvOY5jaQ5FNzbcunUnYy 5UYCm9ucHYWBp2XfM6PYPI1VnoBKiuQ= X-Received: by 2002:a67:ecc1:: with SMTP id i1mr3635952vsp.145.1582923111198; Fri, 28 Feb 2020 12:51:51 -0800 (PST) Received: from alain.c.googlers.com.com (39.119.74.34.bc.googleusercontent.com. [34.74.119.39]) by smtp.gmail.com with ESMTPSA id 22sm3290201vkz.39.2020.02.28.12.51.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Feb 2020 12:51:50 -0800 (PST) From: Alain Michaud To: linux-bluetooth@vger.kernel.org Cc: Alain Michaud Subject: [PATCH v1] bluetooth: guard against controllers sending zero'd events Date: Fri, 28 Feb 2020 20:51:46 +0000 Message-Id: <20200228205146.161229-1-alainm@chromium.org> X-Mailer: git-send-email 2.25.0.265.gbab2e86ba0-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Some controllers have been observed to send zero'd events under some conditions. This change guards against this condition as well as adding a trace to facilitate diagnosability of this condition. Signed-off-by: Alain Michaud --- net/bluetooth/hci_event.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 591e7477e925..f865eddb8d69 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5868,7 +5868,8 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) u8 status = 0, event = hdr->evt, req_evt = 0; u16 opcode = HCI_OP_NOP; - if (hdev->sent_cmd && bt_cb(hdev->sent_cmd)->hci.req_event == event) { + if (hdev->sent_cmd && event && + bt_cb(hdev->sent_cmd)->hci.req_event == event) { struct hci_command_hdr *cmd_hdr = (void *) hdev->sent_cmd->data; opcode = __le16_to_cpu(cmd_hdr->opcode); hci_req_cmd_complete(hdev, opcode, status, &req_complete, @@ -5876,6 +5877,9 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) req_evt = event; } + if (!event) + BT_ERR("Received unexpected HCI Event 00000000"); + /* If it looks like we might end up having to call * req_complete_skb, store a pristine copy of the skb since the * various handlers may modify the original one through -- 2.25.0.265.gbab2e86ba0-goog