From patchwork Tue Sep 26 15:11:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 9972281 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AAEDE6037E for ; Tue, 26 Sep 2017 15:11:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D9AE288C6 for ; Tue, 26 Sep 2017 15:11:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92845289CB; Tue, 26 Sep 2017 15:11:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C92A288C6 for ; Tue, 26 Sep 2017 15:11:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S969355AbdIZPLl (ORCPT ); Tue, 26 Sep 2017 11:11:41 -0400 Received: from mail-wr0-f181.google.com ([209.85.128.181]:49103 "EHLO mail-wr0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965365AbdIZPLi (ORCPT ); Tue, 26 Sep 2017 11:11:38 -0400 Received: by mail-wr0-f181.google.com with SMTP id 108so13538207wra.5 for ; Tue, 26 Sep 2017 08:11:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=WZI8qlf2SLxls3ohvGFHuFHwKOzokwzlbmFq3C+MU84=; b=js70S0DQxPnzKGRBXtCJjUlAMf/BdMQTC8X81ziRe1D2olZ+XCQwcTToJU3bgnLBBe TKUO3noDtvl0OjoUA3dnIRAwqypM/IOQjmNl1d+31NeWVezVS5lGBG0h2yTV87+3QWxr UzZZZpuSJ/eLLF5vxB7cA0VKB+Jt37L8Z7JrZaAH7HqpHOIkrsNo7kaSt7ht1fx9hDyk 1ZlQWpy4rAnUU9KgIVTLw9tOas4RrS5z+ShMMMUA3zTcj2slXjNXVdYSx6af+og4gLBa O2QA03qDMUDtr3xOjcQOlPfI0IVDF9BdTJr+QQRZyicRH9W25NeEETjVML7nP+vCFm1u wreg== 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; bh=WZI8qlf2SLxls3ohvGFHuFHwKOzokwzlbmFq3C+MU84=; b=LU/vAplJnmtlWSDxUnVNb7pUECJZU95Qcz+KNiPyZOq5xyhVgfUu70RS50Q6ihGL4U wsjOzPs2akZAEqmm1jG8Dl+6iWSqfDe73UqozA1CGlnZwuSuy0/ExUSNCGwaT8ARhJg0 2e1jPX0y7ktj/VWb1PisAb+jRxKs9M0VdfRwwAKe0vlrLMqnGVtKdmBWF01HsqMj1Dzc b0569uaNb+Z8kXtu+/Wox81nqcLawcW0jpU/I5D3lzByxCZe5rvS/zinaFlfsy6cfMbU MaaQNzQ9DzqTmOnT5AlfYNcEO7HhyvEkDdb1AOVDB4JY4nXK/ybr9bEs7Ro4+ktYeXum AagA== X-Gm-Message-State: AHPjjUi93dM5WJgmieGoWFZoIX5RkY/EVBcwpkUJz9cwMtLubjQcrfOw 23A4kaf1Wg8W3iOt8eUSUNA/ug== X-Google-Smtp-Source: AOwi7QB47/xZPExYJmR2Ssq2sFDDsXAPTpNHr0mvZwbVPK9hqAoLnDufxpuQQu6h451KFalOxZQysg== X-Received: by 10.223.160.221 with SMTP id n29mr9508881wrn.214.1506438697018; Tue, 26 Sep 2017 08:11:37 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:f560:cb15:a6fe:5f28]) by smtp.gmail.com with ESMTPSA id v5sm1727643wme.5.2017.09.26.08.11.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Sep 2017 08:11:36 -0700 (PDT) Received: by andreyknvl0.muc.corp.google.com (Postfix, from userid 206546) id 152C2180841; Tue, 26 Sep 2017 17:11:34 +0200 (CEST) From: Andrey Konovalov To: Christian Lamparter , Kalle Valo , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Dmitry Vyukov , Kostya Serebryany , Andrey Konovalov Subject: [PATCH v2] p54: don't unregister leds when they are not initialized Date: Tue, 26 Sep 2017 17:11:33 +0200 Message-Id: <17c60ebcc8ce7f20de41a55087d24dfdfca09c67.1506438620.git.andreyknvl@google.com> X-Mailer: git-send-email 2.14.1.821.g8fa685d3b7-goog Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ieee80211_register_hw() in p54_register_common() may fail and leds won't get initialized. Currently p54_unregister_common() doesn't check that and always calls p54_unregister_leds(). The fix is to check priv->registered flag before calling p54_unregister_leds(). Found by syzkaller. INFO: trying to register non-static key. the code is fine but needs lockdep annotation. turning off the locking correctness validator. CPU: 1 PID: 1404 Comm: kworker/1:1 Not tainted 4.14.0-rc1-42251-gebb2c2437d80-dirty #205 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 Workqueue: usb_hub_wq hub_event Call Trace: __dump_stack lib/dump_stack.c:16 dump_stack+0x292/0x395 lib/dump_stack.c:52 register_lock_class+0x6c4/0x1a00 kernel/locking/lockdep.c:769 __lock_acquire+0x27e/0x4550 kernel/locking/lockdep.c:3385 lock_acquire+0x259/0x620 kernel/locking/lockdep.c:4002 flush_work+0xf0/0x8c0 kernel/workqueue.c:2886 __cancel_work_timer+0x51d/0x870 kernel/workqueue.c:2961 cancel_delayed_work_sync+0x1f/0x30 kernel/workqueue.c:3081 p54_unregister_leds+0x6c/0xc0 drivers/net/wireless/intersil/p54/led.c:160 p54_unregister_common+0x3d/0xb0 drivers/net/wireless/intersil/p54/main.c:856 p54u_disconnect+0x86/0x120 drivers/net/wireless/intersil/p54/p54usb.c:1073 usb_unbind_interface+0x21c/0xa90 drivers/usb/core/driver.c:423 __device_release_driver drivers/base/dd.c:861 device_release_driver_internal+0x4f4/0x5c0 drivers/base/dd.c:893 device_release_driver+0x1e/0x30 drivers/base/dd.c:918 bus_remove_device+0x2f4/0x4b0 drivers/base/bus.c:565 device_del+0x5c4/0xab0 drivers/base/core.c:1985 usb_disable_device+0x1e9/0x680 drivers/usb/core/message.c:1170 usb_disconnect+0x260/0x7a0 drivers/usb/core/hub.c:2124 hub_port_connect drivers/usb/core/hub.c:4754 hub_port_connect_change drivers/usb/core/hub.c:5009 port_event drivers/usb/core/hub.c:5115 hub_event+0x1318/0x3740 drivers/usb/core/hub.c:5195 process_one_work+0xc7f/0x1db0 kernel/workqueue.c:2119 process_scheduled_works kernel/workqueue.c:2179 worker_thread+0xb2b/0x1850 kernel/workqueue.c:2255 kthread+0x3a1/0x470 kernel/kthread.c:231 ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:431 Signed-off-by: Andrey Konovalov Acked-by: Christian Lamparter --- changes in v2: - fixed typo in patch subject --- drivers/net/wireless/intersil/p54/main.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/intersil/p54/main.c b/drivers/net/wireless/intersil/p54/main.c index d5a3bf91a03e..ab6d39e12069 100644 --- a/drivers/net/wireless/intersil/p54/main.c +++ b/drivers/net/wireless/intersil/p54/main.c @@ -852,12 +852,11 @@ void p54_unregister_common(struct ieee80211_hw *dev) { struct p54_common *priv = dev->priv; -#ifdef CONFIG_P54_LEDS - p54_unregister_leds(priv); -#endif /* CONFIG_P54_LEDS */ - if (priv->registered) { priv->registered = false; +#ifdef CONFIG_P54_LEDS + p54_unregister_leds(priv); +#endif /* CONFIG_P54_LEDS */ ieee80211_unregister_hw(dev); }