Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2863425rwb; Mon, 19 Sep 2022 11:05:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4IA06oZw6EcD59KvYSBuxtgKrIWWVhF0PNs8+zxFvprNyZNd+pWv8DT0JAA3JiRR/wOKAV X-Received: by 2002:a05:6a00:16c8:b0:53b:3b9f:7283 with SMTP id l8-20020a056a0016c800b0053b3b9f7283mr19481884pfc.46.1663610755408; Mon, 19 Sep 2022 11:05:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663610755; cv=none; d=google.com; s=arc-20160816; b=lobO1ds/p5ZIbKkT6A/Ox124tZtt9loRr30TMalllpAa/jhmf7wLwQ82buQcoQoZyH KiiBsFP7kMPG3e1AXEh7gOtYSoh0qyomoPISNzaS3xjacn01ddguAudnb0kyWMGh5xSn UbY/7kGo/qts1ETpN6eUjHe6zE6cOM442l6zgd+Fyd1bxlENiPJn7Gq7dA8AujwQfRYa Ud/7XFPjVPGXlgz5ZAZwCMkKY3Dhet7RaIv13cwcChfUSaRioJmZaxlMnaJDX//3xrmF +UL0a9p0vKScZpfeUZQoOmEjpyMoYtduUcbbb0OFMKEaZYYl7+8jk0VG5GVYX1Is+wSe oSBw== 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:to:from:dkim-signature; bh=lsxoKrT8ToOYn/aj8iT347uk6DO4+sXKNJGwFCPI71k=; b=W0eCRY8LGdgn6mRU+fhO/PpT+fA+KPPLepPudc5zuDi8eO88iM8bxVBSwK+pczxnI5 pTB2zNJTKykrho5qnyuzfjYABlzLxm74fwv+gYxxOsvSqRJHyCi2MYVfqEEc/EMyEbfz 0tDfEnhNR0izjn+uY5i2u79xinauA+oKehEk1BTkRC3Q1/D+lvT3mj/f2V+MSSCsMAZl OjS34H10hkZz5nm8/e2v5rf6NSyxcQFjWPyNvKI595m2I08D1Htj2hPSfEf1tlFoQq5T xQPL/QyKCRXAE+4XgyTsPqioculgIe3j8DkWh6zjVHW5i0Up7TR59Vn7M3nTIwR6sQ6v kBgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EfXggWyD; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j24-20020a632318000000b00429946b0642si345431pgj.469.2022.09.19.11.05.36; Mon, 19 Sep 2022 11:05:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-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=@gmail.com header.s=20210112 header.b=EfXggWyD; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229749AbiISR5F (ORCPT + 99 others); Mon, 19 Sep 2022 13:57:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229560AbiISR5E (ORCPT ); Mon, 19 Sep 2022 13:57:04 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 675B92126A for ; Mon, 19 Sep 2022 10:57:03 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id a5-20020a17090aa50500b002008eeb040eso6931973pjq.1 for ; Mon, 19 Sep 2022 10:57:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date; bh=lsxoKrT8ToOYn/aj8iT347uk6DO4+sXKNJGwFCPI71k=; b=EfXggWyDV3RG2luy1BeTubBMkOqxpwaun9uObHWTJX/FNVGo8HgtCnsKfCGYQnU6Y2 3scjuR1+4MG7CiF41UNe5rtZGub9aPEj+aFXgTkDX0qGFWXER75L9xtS6IyspzvWc4Lb lNUkd7j8l+ao9gwpq7UMlF1v6mLha6EltP2fhu6bc3xvUz0JVh8bAFKs35A8p2ISZIiO Fd7d5K/5TFbTfeOuI5nhX68P+0kgmIuabwLOVfFkJNr4FNJuE6s+h9ZFFlSO1enPqkWP B+A6QkJNgsuqcccw1EnmuB5rtEt0gC9x6YmLod6dDp2htBCkWrmlxJkGcw39OxOZ7QBp KPag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date; bh=lsxoKrT8ToOYn/aj8iT347uk6DO4+sXKNJGwFCPI71k=; b=SGc4qa8wQPvhNUQXFwVNoe/rFs/lSCbyjm+zU5vmG7uWjbbn8VkWfeaGldEc2I19vN WU3QX/FjVNdPsi1/MAMnD7Rhdy36QzYpP4fysQNbKH1H1MvSQPDclR33kEOB5DJ17Fyd pGcXcJSaxCRpQxVzNyarVjeZ3+XO3KTDRBoXbg9tPj7eN7MmP5ryyD7AHFD952DDAtIM JytSn7CsDd2VDqg0hVJx3wUtopXNIbeowKJgc3cURztkUnXfQaLvuywj1SlHoc+1aMhk +a0AH0qcc/hsbCnSoK+6htwdjis1Fc8Y18GzUeYfOMMQAZU+rQ9QSZoYVXhm7+si+iwJ fVxg== X-Gm-Message-State: ACgBeo1l6RDJ7WPPr+/23Ij357JQ9pFgvlTRglGbXZjV7kxRUO+U1llm 5kp4UI4Yd3YZL/RvaSA0Bq9+/Sbeh1U= X-Received: by 2002:a17:90b:4f4b:b0:200:876b:c1c8 with SMTP id pj11-20020a17090b4f4b00b00200876bc1c8mr33115481pjb.32.1663610222354; Mon, 19 Sep 2022 10:57:02 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id a1-20020aa794a1000000b005361f6a0573sm20579120pfl.44.2022.09.19.10.57.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 10:57:01 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH 1/2] Bluetooth: hci_sysfs: Fix attempting to call device_add multiple times Date: Mon, 19 Sep 2022 10:56:59 -0700 Message-Id: <20220919175700.1649726-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz 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 --- 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) { -- 2.37.3