Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp1338652pxb; Sat, 9 Jan 2021 16:34:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJxm0EEViAwd0Esq+q44alnb6gAamMnZzYXZqnJ9ivPH+kpMWUZ768oRMsubzEoWuCf6JRaV X-Received: by 2002:aa7:c358:: with SMTP id j24mr9854405edr.265.1610238848419; Sat, 09 Jan 2021 16:34:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610238848; cv=none; d=google.com; s=arc-20160816; b=RAbUkMdjQl5phK1beY9vjeKDbw2u0SNKvlCVpj1KAwz5ObK1xYdRR4JbHmCASAmQ2a ZhBbOfDvqzOjcYCAK+AzGMTX7QpOPEiUZOxainZE3EvNDJqKCsmqcL+Bp4SOkFcD+Ihw c8+U4HoCd6/ERVycIYW91uo95BlaUy4ae2Fyu75+fYgFdZqR1r4T4eRRO00tUvYIN7Q3 MT0zwHiBVaJ9TaDiGIPZr9xNOF2e6zXutuuSyLnlpMgB6efozK0jpsw7si8iHLCIkS0F f5k5vM1IeYEKosXaY0yLEXL5tXA/o3/sJPLIkYzrMb6N0x/WS80Gw13TkjCTpFMU91xn FC2Q== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=3nnF+bkgtjz25uaf0FNhzS1otuiCUw75IC3zjjwwTtA=; b=X1Sv9JTtv6syVLmEZwbhk4IGWKHpqGgcKadIvhr4Paw58mNxZskxxeCxSyysn+VApu 40bWxtEW1jqXKrhag8/FxxWvSjw8fpfSuiSrwta6ynXAlbO8MCeFSZ158d6q37D/2dPO UqNapRvzJIMRkWfZRi8qv/DAh2xFn4gB3VkszMLi+r3aGwfo+fzmW5SWUg79lkhSrN8e T+8KIcPkqEMurE2P8PqvEj7aq2klZH5TS44OgB3CxSEPo9BI76jgdEejbZBxeXicKXCM GLj15nTXsJ3ANjqN7D2vV4v7guwLpoNX9DWNz9IzFGs7Tb3uVYrplf6IVMyZTKs3+9op R+zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cPXcKf23; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id i10si5203112ejd.572.2021.01.09.16.33.29; Sat, 09 Jan 2021 16:34:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-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=@chromium.org header.s=google header.b=cPXcKf23; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 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 S1726428AbhAJAbW (ORCPT + 99 others); Sat, 9 Jan 2021 19:31:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726198AbhAJAbW (ORCPT ); Sat, 9 Jan 2021 19:31:22 -0500 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D589C061786 for ; Sat, 9 Jan 2021 16:30:42 -0800 (PST) Received: by mail-pf1-x432.google.com with SMTP id w2so830593pfc.13 for ; Sat, 09 Jan 2021 16:30:42 -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=3nnF+bkgtjz25uaf0FNhzS1otuiCUw75IC3zjjwwTtA=; b=cPXcKf23RsXBEUQrHLhhCW2j9KvHV/yxsxc/89zLsF0opyf9cu6nEPZ4ZjcqJPwuF8 fqE7SRTSXwjJ24WYAZXjNn5eEA3C81PQZ8i68BkMrKIjIJiGlOBP4UntEjpoMLR4Avte WCksCfUcriSCEykqLnvfEMPpOa25V3oAVMYrY= 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=3nnF+bkgtjz25uaf0FNhzS1otuiCUw75IC3zjjwwTtA=; b=hC9Wz4pjiP1KwFRBPE+jJDGPxVWgStJkVANhzyUtvaMtuxR9ikGtKwpWtuJRgf7Q4R 8lFQEVy0v2nqyxdR7Hsk+ui5vAXOme1HZFBd6vroiSSYRHCFtdiYDJ0jhGCZFEDZO0Al VMFNVLOFgbarqJ31jW8x4/nOFnOM+u6SdiDl+FAilOW8i8bb33yQkFbvDAmO9PDEahN3 RijX5kHjTvxG+5sec4jCQ5ErMYMtijbCKn6sceXRJ0Asv8h9NAO8SlFWw4PQqoF3sjfb 9F9IxVMh5Rr95H/cdxCaHVFvrAp/3qXTXPw9hiKwZkYfrfJBHHBak68c2gXg1/wLl27H 8qrg== X-Gm-Message-State: AOAM530q/7Kkw0oGdv8Qx87oOfBZ39SCmnWdq0xEeN6ynKjvOcztq6oB 1f3AH6mNyI9Gg3URbxJB2M0vV/MhUtW3Sg== X-Received: by 2002:a63:2902:: with SMTP id p2mr13572692pgp.274.1610238641390; Sat, 09 Jan 2021 16:30:41 -0800 (PST) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id a19sm13041299pfi.130.2021.01.09.16.30.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Jan 2021 16:30:40 -0800 (PST) From: Sonny Sasaka To: linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka Subject: [PATCH BlueZ] input/hog: Fix double registering report value callbacks Date: Sat, 9 Jan 2021 16:30:33 -0800 Message-Id: <20210110003033.2528-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org In commit 23b69ab3e484 ("input/hog: Cache the HID report map"), we optimized HOG reconnection by registering report value callbacks early, but there was a bug where we also re-register the same report value callbacks after at CCC write callback. We should handle this case by avoiding the second callback register if we know we have done it earlier. --- profiles/input/hog-lib.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c index 1f132aa4c..089f42826 100644 --- a/profiles/input/hog-lib.c +++ b/profiles/input/hog-lib.c @@ -80,6 +80,7 @@ struct bt_hog { struct bt_uhid *uhid; int uhid_fd; bool uhid_created; + bool report_value_cb_registered; gboolean has_report_id; uint16_t bcdhid; uint8_t bcountrycode; @@ -336,6 +337,13 @@ static void report_ccc_written_cb(guint8 status, const guint8 *pdu, return; } + /* If we already had the report map cache, we must have registered UHID + * and the report value callbacks. In that case, don't re-register the + * report value callbacks here. + */ + if (hog->report_value_cb_registered) + return; + report->notifyid = g_attrib_register(hog->attrib, ATT_OP_HANDLE_NOTIFY, report->value_handle, @@ -1703,6 +1711,8 @@ bool bt_hog_attach(struct bt_hog *hog, void *gatt) report_value_cb, r, NULL); } + hog->report_value_cb_registered = true; + return true; } @@ -1753,6 +1763,8 @@ void bt_hog_detach(struct bt_hog *hog) } } + hog->report_value_cb_registered = false; + if (hog->scpp) bt_scpp_detach(hog->scpp); -- 2.29.2