From patchwork Sat Oct 22 07:27:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7609 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1106626wrr; Sat, 22 Oct 2022 01:38:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM47xKb9qaNFLnua34C7nQybC7cwmG15zfU4DjsiBX64W01rMjh74Hj1P2uFlphsUg9T7JfJ X-Received: by 2002:a17:907:3f0c:b0:78e:2090:6924 with SMTP id hq12-20020a1709073f0c00b0078e20906924mr19635425ejc.332.1666427907733; Sat, 22 Oct 2022 01:38:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666427907; cv=none; d=google.com; s=arc-20160816; b=dSdxG3dfKifBl8AkMzrzdKvrWWEs8LK3F5MqaFHM9eiOitMOZZfCYHuf706rhzZ/W3 VgoWx/4zC9xkaATjR2uKGcAMaA193UMaCDGURd0jqLbeK9z2C7XK4J+RQsn0qLCpulYp 1pwQumj+Jryx6UH08cDM2tNtjq8mVJaGQj5GGr/9qSp+xTOu0CJdueLAlQbPq5tIDZfk 5osc2yZ61btP0WmlDCmURhqE3o/Z7SiYdzFbq5Kc+kL3v0po0L+uVpckK3gtkNfHJ7oC 48RGr79iP0A0wufuvfQTG8TdW2ESegrL3Lop6mjxBqIpVdLgQkRv85EM/2DxSN+GmJ9Z P+nw== 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=NJZfZNdcqE3SrvhkFsD6A4LRPV71IaZuZ5cU8F13qXA=; b=Y5ZME4ND2se0lNrLR9ftCPFKMrtqwdyK/uMfDYFOghRevs2h8eljiK6CTBr1g3P8PK /cdOUlQD/27cvoCG+6HzkBH2FP55pkADYdfmo7gjTzDBhMWxYlD8OV2J4sm1DbOEckHw x9B72NviKL+yadcEiOipCjZu7IhNE/sLnZDsklk/EDJxQCCLNSQUkLjwl8rbov8JRooZ xrRY6VAXeCrrS9JhwTmaeDD2kHJ9B+VYXoaDm7p4iEIyUgSckYDQ67m1tjMR5f1Pgv2F sGfv0YOvjaZNPMlgRx2imtatDOBVJoDmyf4im5pwcw+MrriAe2M/m/D0y04QZ+R71IOb trYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aUS5jjjz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn17-20020a1709070d1100b0078e254ae418si22046553ejc.640.2022.10.22.01.37.56; Sat, 22 Oct 2022 01:38:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aUS5jjjz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S234098AbiJVIdj (ORCPT + 99 others); Sat, 22 Oct 2022 04:33:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234214AbiJVI36 (ORCPT ); Sat, 22 Oct 2022 04:29:58 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F9162D03AD; Sat, 22 Oct 2022 01:02:15 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id C72FEB82DF1; Sat, 22 Oct 2022 08:01:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 380B1C433C1; Sat, 22 Oct 2022 08:01:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425686; bh=Qq/nS/EG95y0I/Z0ahk81L6aZDYvt5NYsst/VyPOYko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aUS5jjjz0PbNuWuYx4O3lPB4RPDcRbk6sKrY6UmnPlFvUoFg4BIGFPivGgz1afU0k ISm/l+zB3RDoyMRxTzRyeZXCmnUsTmW2dNZLe7IyrNBLlLUl1JorMwmEaSQ/nbHlnM LEVwFQFzHcKtrbTaf2ifV0chuWXI9Cw0HgEl//Ak= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Luiz Augusto von Dentz , Hawkins Jiawei , Sasha Levin Subject: [PATCH 5.19 582/717] Bluetooth: hci_sysfs: Fix attempting to call device_add multiple times Date: Sat, 22 Oct 2022 09:27:41 +0200 Message-Id: <20221022072524.164978201@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747376310019550582?= X-GMAIL-MSGID: =?utf-8?q?1747376310019550582?= From: Luiz Augusto von Dentz [ Upstream commit 448a496f760664d3e2e79466aa1787e6abc922b5 ] device_add shall not be called multiple times as stated in its documentation: 'Do not call this routine or device_register() more than once for any device structure' Syzkaller reports a bug as follows [1]: ------------[ cut here ]------------ kernel BUG at lib/list_debug.c:33! invalid opcode: 0000 [#1] PREEMPT SMP KASAN [...] Call Trace: __list_add include/linux/list.h:69 [inline] list_add_tail include/linux/list.h:102 [inline] kobj_kset_join lib/kobject.c:164 [inline] kobject_add_internal+0x18f/0x8f0 lib/kobject.c:214 kobject_add_varg lib/kobject.c:358 [inline] kobject_add+0x150/0x1c0 lib/kobject.c:410 device_add+0x368/0x1e90 drivers/base/core.c:3452 hci_conn_add_sysfs+0x9b/0x1b0 net/bluetooth/hci_sysfs.c:53 hci_le_cis_estabilished_evt+0x57c/0xae0 net/bluetooth/hci_event.c:6799 hci_le_meta_evt+0x2b8/0x510 net/bluetooth/hci_event.c:7110 hci_event_func net/bluetooth/hci_event.c:7440 [inline] hci_event_packet+0x63d/0xfd0 net/bluetooth/hci_event.c:7495 hci_rx_work+0xae7/0x1230 net/bluetooth/hci_core.c:4007 process_one_work+0x991/0x1610 kernel/workqueue.c:2289 worker_thread+0x665/0x1080 kernel/workqueue.c:2436 kthread+0x2e4/0x3a0 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306 Link: https://syzkaller.appspot.com/bug?id=da3246e2d33afdb92d66bc166a0934c5b146404a Signed-off-by: Luiz Augusto von Dentz Tested-by: Hawkins Jiawei Signed-off-by: Sasha Levin --- net/bluetooth/hci_sysfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index 4e3e0451b08c..08542dfc2dc5 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c @@ -48,6 +48,9 @@ void hci_conn_add_sysfs(struct hci_conn *conn) BT_DBG("conn %p", conn); + if (device_is_registered(&conn->dev)) + return; + dev_set_name(&conn->dev, "%s:%d", hdev->name, conn->handle); if (device_add(&conn->dev) < 0) {