From patchwork Mon Aug 19 20:53:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 820705 Received: from mail-vk1-f171.google.com (mail-vk1-f171.google.com [209.85.221.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D21F15958A for ; Mon, 19 Aug 2024 20:53:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724100789; cv=none; b=pRWqCDB179UUW55Hg8iFjT3DtzST780vjX2bk4NfcGnzqBOyloiD3bPUJGynw6+sQXFtvWkqGigTGew5HrtOdyh9sEwJQ0HCCfwhrTIU5kMKhiKFpAvBnBGHqpZ9CRbHPioKZBg4s2pi/FJRm99lyvwKf1xiHqkQ/49MMi18FQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724100789; c=relaxed/simple; bh=bLpDOyVokrPaezJe8X7NGkIgzqAVumMBbGxLDLqCyaM=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=DJc+YD12a92jNyxsM54V4Mr2X6I3KHpORxr2l4zFUz+pFdxc+gNmto9d28srxQQQ5XWduQl295TFLjO+Vpb70w4CM098SNIlmpDeAKnSJX+MK9nBZOj8WdqNrkkXehiULff9oJgO4tDamGNENL/pOZXLucHhpfmBXFe/uKJRbrA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZLUdwerp; arc=none smtp.client-ip=209.85.221.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZLUdwerp" Received: by mail-vk1-f171.google.com with SMTP id 71dfb90a1353d-4f6e36ea1ebso1574489e0c.0 for ; Mon, 19 Aug 2024 13:53:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724100786; x=1724705586; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=7sqZsEDPGsUzK05lHRMK23xTV6lURBucq3CEq/C5814=; b=ZLUdwerp6vCtonwaUpPCXMNGT2Fs0MUxVCUdAD9zyT/TIa+cSkgKwqFy8tHgf/nBT+ qTVCSyF5Lm2YuLEvjLv93N6zzvt1V4JNo5ae8mqwU5ON5ld5rj1S/Z8zLPDK/p6xAKgZ pBRHBiRZeFV7sOogGQ4vUIN7Onp2SHCq6LhNPqiRNR960EMNV5Bp2wjRQK7WoQQrVyO5 wjbflWGtK3MvKXDLISFBcKwUE87XHtodHWVfZOuDrsROGlkjqlLYpJFJy2VLZI9ruzQh H0TceKHEKk21+dmzIXiuhBA5V6EP+xn2YFv6h6lZDbiVtJIm0q13JLt90QOyP42oUXSH 88Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724100786; x=1724705586; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7sqZsEDPGsUzK05lHRMK23xTV6lURBucq3CEq/C5814=; b=Gd9lp74gDV9yGQ+VPLNxcZAU0INCb/T8T7XHctn+0mDtWTOmIwFrpDPh/vB82ajp6P RIq2jFdZ4ZK8b7g931+fcNePLNHrxYeyoTxvxAdiH28yzrgqKoRgAVOMPi7XNVJfyEBe grV7gmT4vQLt68mv3d4kybRu0NlThTbHJjUOB277FbhiGhB+y/nw4H4QRXU4S7kEGDT0 I583fJ6M/NmCuQjBcfhuT2hY5JzwLdPAsbyPwkNSBSiw0RtHPzFVYkohgi7XygnRgqUO 8mX1VpDseqvf+SxZIiyeWBexWOpMi3ikHaEbIRP3V45UiJYoURFsIzOa4OWv9mQ4I+rR CIsQ== X-Gm-Message-State: AOJu0YyT3+4xh3NvN/quw8CXI9zmpwzwXg2XdGh8zpD6sBdb+TkoHduu /CMXdArsWyGA/rDe8UQuX6EOzV4ROIj3002/xpnM+Y5EzRt3fbdpLZOB9A== X-Google-Smtp-Source: AGHT+IGCckv3BMGeuXOMOlEU+9Y4g1Kdp0Zbk8zRV9WFRhs9W20P3eepqbnqOQWTmp0aYScGXFeE1w== X-Received: by 2002:a05:6122:2013:b0:4ef:5744:46a with SMTP id 71dfb90a1353d-4fcd89fd752mr482819e0c.1.1724100786351; Mon, 19 Aug 2024 13:53:06 -0700 (PDT) Received: from lvondent-mobl5.. (syn-107-146-107-067.res.spectrum.com. [107.146.107.67]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-4fc5b9cb136sm1155049e0c.50.2024.08.19.13.53.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 13:53:05 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v1 1/2] hog-lib: Fix calling bt_uhid_destroy with invalid instance Date: Mon, 19 Aug 2024 16:53:03 -0400 Message-ID: <20240819205304.60594-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.46.0 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luiz Augusto von Dentz If the hog->uhid cannot be created then it is pointless to call bt_uhid_destroy as it will likely just produce bogus output as in: https://github.com/bluez/bluez/issues/529#issuecomment-2297350805 --- profiles/input/hog-lib.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c index 1b4aca07486b..729603702e5f 100644 --- a/profiles/input/hog-lib.c +++ b/profiles/input/hog-lib.c @@ -830,14 +830,16 @@ static void uhid_destroy(struct bt_hog *hog, bool force) { int err; + if (!hog->uhid) + return; + + bt_uhid_unregister_all(hog->uhid); + err = bt_uhid_destroy(hog->uhid, force); if (err < 0) { error("bt_uhid_destroy: %s", strerror(-err)); return; } - - if (bt_uhid_created(hog->uhid)) - bt_uhid_unregister_all(hog->uhid); } static void set_report(struct uhid_event *ev, void *user_data) From patchwork Mon Aug 19 20:53:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 820414 Received: from mail-vk1-f179.google.com (mail-vk1-f179.google.com [209.85.221.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 111A3158D8D for ; Mon, 19 Aug 2024 20:53:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724100792; cv=none; b=GqvfnMKFJxDZKr+Gv4W+bNrSquypl/x7Bo+S8mTgFDZuFaWM4ZOxhCnMTa+XLLHT7QbMxvQDk/pbYgO9EsNlrn+9AZxy3GoJ7jApj/l+FgxdRJj2YunA1wh+VUN5W6KgGP5aY6ZhEG/Yk0DOZ922KSW1LYPzIQgfh5LbMPx+5ys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724100792; c=relaxed/simple; bh=pjQP/CuiMZHWVY/JfVSX3Yx0VjTLUtqFrfzohRJxkGM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S0ZukBefYIVhS4IIwHp0LDb5I3VPBUmY6b0tC0GCjwEkR2jIXbS8mtbQPgBZsdACWIz6vpZK2nVqqXMQ6imlRVx5JyD7wNjSSGCYQREtHW5onXcwJjuPTYRkHT9H0lohnnAXQTxcF5oNfu1Te2m+ezZ9fqO4+km3sLg1v+2cv6M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=iX7lxW0V; arc=none smtp.client-ip=209.85.221.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iX7lxW0V" Received: by mail-vk1-f179.google.com with SMTP id 71dfb90a1353d-4f2c8e99c0fso1602461e0c.1 for ; Mon, 19 Aug 2024 13:53:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724100788; x=1724705588; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=weM2o/FJseL1E57zA4/JUAE+buZRqS1b0drKnHzV1SY=; b=iX7lxW0VSnIgWYPU0+mUfxHm+IET6Cgz9pZKNBALoRMXBvQaxY2AaFlU4uo87hv6PF q6tTJARFB4X17/OQckd+ueZhfCasi+lcvVF6Ux9Kxkp3FMoEzz2kjPO5anUXSTU2csdp y+vm8kwmngKHdWqm8qWlYvZGyt+NhhcFOXHeLGodbpTSFNcWc4HhFpMX+X7pC8hya6DD +1ffzosPNwi40PxHuUKrjpDs2U4JZboDNAytti8NQmn9fkQY5Gdj0jeXl08zLGdAX+nw UJhYhPugjx/OpOKp1aymujgshcZekjtwhM4QjL8M6Jw1INingSOHmzjBYpvnUxA7pO5I 93qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724100788; x=1724705588; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=weM2o/FJseL1E57zA4/JUAE+buZRqS1b0drKnHzV1SY=; b=cyOy9vc5/C0TZ45Z+Cyefs9vfEt6hW4k4B42ZXNypT3Fj5p2aSKuQP1oIdpnK/jcR0 LFo/g3CZ/MoMJgkaGE/6xLdKCN3/CZjB83ZOY78Onsyk0J9PhNyCFWzFn0vLpk1flwW7 zW6ny2giAolO5iYkQOItsYL5ulGOuEHJTe5llyxcoPi93U74/ZnR62A4eu/qM/mveCje NwiZS/ow0U+SPYCLHc2tSTvnDN2Qt+O2B3kPh6/GjJELmlKlh24R08ZN7tuNTkkR7H5z CBOPYVodBVikoKKRCbeJBddpOhiWVrkj6vOEADxkoU03nq9tr+i8T0V0VhXOq2hSn8rr NQdw== X-Gm-Message-State: AOJu0Yx50OseSLfU1gat35hJiPutagr1Zk/HYqdyxwXFyX4uhWTcZbCp uuCQBPXf1dCyUn5S8ZVIQDEqQz8KXcCmXgXzl3NZ1D1hGESCr+CLoXi5zg== X-Google-Smtp-Source: AGHT+IEWuhiODu8VSM9SvdejNmZqFix0bCKOdFxv0x36rxTLffQ0l4k1BRp5EIAxuB1iFL8IeU4RYg== X-Received: by 2002:a05:6122:3c84:b0:4f5:1ea3:736f with SMTP id 71dfb90a1353d-4fc6c9f392dmr15381188e0c.13.1724100788170; Mon, 19 Aug 2024 13:53:08 -0700 (PDT) Received: from lvondent-mobl5.. (syn-107-146-107-067.res.spectrum.com. [107.146.107.67]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-4fc5b9cb136sm1155049e0c.50.2024.08.19.13.53.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 13:53:07 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v1 2/2] hog-lib: Add logging when bt_uhid_new fails Date: Mon, 19 Aug 2024 16:53:04 -0400 Message-ID: <20240819205304.60594-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240819205304.60594-1-luiz.dentz@gmail.com> References: <20240819205304.60594-1-luiz.dentz@gmail.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luiz Augusto von Dentz If bt_uhid_new fails there is likely a problem with uHID module or bluetoothd don't have previleges to access /dev/uhid. --- profiles/input/hog-lib.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c index 729603702e5f..22599f71a394 100644 --- a/profiles/input/hog-lib.c +++ b/profiles/input/hog-lib.c @@ -1421,23 +1421,29 @@ static struct bt_hog *hog_new(int fd, const char *name, uint16_t vendor, uint8_t type, struct gatt_db_attribute *attr) { + struct bt_uhid *uhid; struct bt_hog *hog; + if (fd < 0) + uhid = bt_uhid_new_default(); + else + uhid = bt_uhid_new(fd); + + if (!uhid) { + DBG("Unable to create UHID"); + return NULL; + } + hog = g_try_new0(struct bt_hog, 1); if (!hog) return NULL; hog->gatt_op = queue_new(); hog->bas = queue_new(); - - if (fd < 0) - hog->uhid = bt_uhid_new_default(); - else - hog->uhid = bt_uhid_new(fd); - hog->uhid_fd = fd; + hog->uhid = uhid; - if (!hog->gatt_op || !hog->bas || !hog->uhid) { + if (!hog->gatt_op || !hog->bas) { hog_free(hog); return NULL; }