Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3909982ybz; Mon, 20 Apr 2020 11:41:09 -0700 (PDT) X-Google-Smtp-Source: APiQypLmiuQ78L4zsD53y9szNj1x16+wTHqWT1Wox8oPPmJq+UyrvD5JjLJRPskJ3R/qPKtkOt+R X-Received: by 2002:aa7:d0d6:: with SMTP id u22mr15964920edo.262.1587408069100; Mon, 20 Apr 2020 11:41:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587408069; cv=none; d=google.com; s=arc-20160816; b=CddNOxWHomqVeFNtWEcDKN+jlY3RxnwYrmzcnJkWa4qXsubSw7SnSpWpoflW1zLjrh 9H0/xENXzNQyByQJvRgEfjGJCjU0xgXFMqxd497LNlzWmz6YsQHlDAxcED4WVdXALBjV dLpp8GqQLQqtcwSOwWwAHS31fW7MSu4Fc7Cf8cWcwr8V6eZWWDXzJhPhD7xpygvNz7+D oawtrYMFkVRROOdryDaDA4a8OSRS9KCxTYQQb8C22D5gDrQWYQ3nArHST9FtlEzuIzo+ 1DXn8X/ONaMmTmwjhpDrTQnmTL/Y+8tyGd+xBUyy175SvM3rsg59HQ9A1KTfTjxgnKg5 XgkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=5mIAI4wftxrpWO4YCaXmTusKEOUGeo0wolgJ9tTUftE=; b=U80OoEJHiVnh3WqtHcVLZjV/gf9ctRkJsGoWWxVreojruGRtKKj74yvYxV6XleLpCN MDnLNLs4ih1lpQk1DWcv/+4fMAKl0ILXk7PnQmtM5TQTQJCEUJ+shyxxj0Tp7WA7lyhh KxxDtQ5GA/4DrQLYLWrw+iBKYRbDo47e70rT06hnemsuQYHK7zx8ACGGtN2JaHDuTFlF seqjkql9rBjVYBG+cdNHWA5bAOmCfKJUZndkh9nRcK7hEDt0ggk+9QD2GgrdQ7WmJczy ubl50maLi4Aa8r/s9/Sgyipmn50MQr2vaJHhkmj3s0JgrAc3OsogMLLNOs2N5KZnjlkI RI3A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r24si195940edc.217.2020.04.20.11.40.44; Mon, 20 Apr 2020 11:41:09 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726392AbgDTSkj (ORCPT + 99 others); Mon, 20 Apr 2020 14:40:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725613AbgDTSkj (ORCPT ); Mon, 20 Apr 2020 14:40:39 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DA45C061A0C for ; Mon, 20 Apr 2020 11:40:39 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: scerveau) with ESMTPSA id 5CA9E2A0467 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= To: linux-bluetooth@vger.kernel.org Cc: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Subject: [PATCH 1/1] add hog ref before adding to instances Date: Mon, 20 Apr 2020 20:40:29 +0200 Message-Id: <20200420184029.22891-1-scerveau@collabora.com> X-Mailer: git-send-email 2.17.1 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org To avoid a double hog free, need to add a ref when adding the hog to the slist. This bug has been reproduced with gamepad-8718 which was connecting/disconnecting frantically. Fix also a typo in the method hog_attach_instance --- profiles/input/hog-lib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c index 9c5c814a7..8fb0283ca 100644 --- a/profiles/input/hog-lib.c +++ b/profiles/input/hog-lib.c @@ -1357,7 +1357,7 @@ static struct bt_hog *hog_new(int fd, const char *name, uint16_t vendor, return hog; } -static void hog_attach_instace(struct bt_hog *hog, +static void hog_attach_instance(struct bt_hog *hog, struct gatt_db_attribute *attr) { struct bt_hog *instance; @@ -1373,14 +1373,14 @@ static void hog_attach_instace(struct bt_hog *hog, if (!instance) return; - hog->instances = g_slist_append(hog->instances, instance); + hog->instances = g_slist_append(hog->instances, bt_hog_ref(instance)); } static void foreach_hog_service(struct gatt_db_attribute *attr, void *user_data) { struct bt_hog *hog = user_data; - hog_attach_instace(hog, attr); + hog_attach_instance(hog, attr); } static void dis_notify(uint8_t source, uint16_t vendor, uint16_t product, -- 2.17.1