Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp776655ybt; Fri, 19 Jun 2020 13:29:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8WU1AQMT2dpZBT5VemZYldQGpftkqxReBU6Sc25rFSpMvBgHJQtKYqlGVukTs5kWzL3X/ X-Received: by 2002:a17:906:938b:: with SMTP id l11mr5078135ejx.99.1592598553912; Fri, 19 Jun 2020 13:29:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592598553; cv=none; d=google.com; s=arc-20160816; b=bN65F80MYtY0TjzRD+DksV/h3h4DBzLr1U0EvYp1mRNVx9fj3ELXHq5ifrQC7NewAh mMOE+evWYqM7SrI8zKuCtl9jbWfbvj0fp0M2XU6hUQ73nBD8JBA56pyCibrqN8euGLXG GYB+A9ptBsxcH91je+41x21i2PTr1aibDRrm+vs+Aexc0unfwimFiGMgcYJx3lUniHmy hVKfr+f/JCrMuGAuVlrBHV9u2tKXZ7rnWnA3CYuGPVo/HUoatMrUkeBjacSZJgkfw9Zp Lb2PAmwNNz+KqLf63jaC1z1x0Y8isj/6spCwzw81zwiTzmyMreZ9LKVQwMNOaWavpFkZ 6Ohw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JocqXVx7ECnUGL4aeiieYooLG8vJU1Q5H+tBlR9EoTM=; b=RgNGb4TBLxxwpHIGcvB0CwvfM6S/sy0RPttD13S/QZ1OIWmcNqIjr00Lcim4uQbGMn YaXb8VrOucZ1JIvf5r1kPebj5V0HBJsHaVG/IGfFn7ZqdPKgDtCPmNRFKmMc1t3GidYT oq4f7jPOzowh/EHIZ8KoZvmQAnr4IDsjf8ZCmTAfNd5MuZDfcoaT+ENHxYA1ZJRX5wHO EUMh8eLhDvurts7vGceXnSwNsis4SG9In7a/GHEeDyrBDi9cTKnHcxL9pCApeStWUvNE B2WCigv7e1q6ilW0TWaNc5pXl3oRMR1Mf4sLVffT9n2wgJMpoN0k7MdA5d0vJ1yVkJcX vt9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TNJ8kHQm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id be28si4661900edb.525.2020.06.19.13.28.51; Fri, 19 Jun 2020 13:29:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TNJ8kHQm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389331AbgFSPDm (ORCPT + 99 others); Fri, 19 Jun 2020 11:03:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:60028 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390968AbgFSPDQ (ORCPT ); Fri, 19 Jun 2020 11:03:16 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 004E6206DB; Fri, 19 Jun 2020 15:03:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592578996; bh=W2jMoETnaFmFGYNSvufQG5lSA4sk7X15UaQ2Ol1DU6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TNJ8kHQm7C2OayoawZ01m7xprgjqZ0Opbk426ncY3BMlUwFKCbfB8fhvrHaVj02Ny FxpOsJMJY6RZ6vtOmaln4clMphWp5EWycz22PGv8Sa97iUqymcMEny27vfYX/+upy3 qvZMmGP/TWl+zaZN5vLpqPWd3Qk3vOZ9W2fqChbE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Marcel Holtmann Subject: [PATCH 4.19 236/267] Bluetooth: hci_bcm: fix freeing not-requested IRQ Date: Fri, 19 Jun 2020 16:33:41 +0200 Message-Id: <20200619141700.028285625@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141648.840376470@linuxfoundation.org> References: <20200619141648.840376470@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michał Mirosław commit 81bd5d0c62437c02caac6b3f942fcda874063cb0 upstream. When BT module can't be initialized, but it has an IRQ, unloading the driver WARNs when trying to free not-yet-requested IRQ. Fix it by noting whether the IRQ was requested. WARNING: CPU: 2 PID: 214 at kernel/irq/devres.c:144 devm_free_irq+0x49/0x4ca [...] WARNING: CPU: 2 PID: 214 at kernel/irq/manage.c:1746 __free_irq+0x8b/0x27c Trying to free already-free IRQ 264 Modules linked in: hci_uart(-) btbcm bluetooth ecdh_generic ecc libaes CPU: 2 PID: 214 Comm: rmmod Tainted: G W 5.6.1mq-00044-ga5f9ea098318-dirty #928 [...] [] (devm_free_irq) from [] (bcm_close+0x97/0x118 [hci_uart]) [] (bcm_close [hci_uart]) from [] (hci_uart_unregister_device+0x33/0x3c [hci_uart]) [] (hci_uart_unregister_device [hci_uart]) from [] (serdev_drv_remove+0x13/0x20) [] (serdev_drv_remove) from [] (device_release_driver_internal+0x97/0x118) [] (device_release_driver_internal) from [] (driver_detach+0x2f/0x58) [] (driver_detach) from [] (bus_remove_driver+0x41/0x94) [] (bus_remove_driver) from [] (bcm_deinit+0x1b/0x740 [hci_uart]) [] (bcm_deinit [hci_uart]) from [] (hci_uart_exit+0x13/0x30 [hci_uart]) [] (hci_uart_exit [hci_uart]) from [] (sys_delete_module+0x109/0x1d0) [] (sys_delete_module) from [] (ret_fast_syscall+0x1/0x5a) [...] Cc: stable@vger.kernel.org Fixes: 6cc4396c8829 ("Bluetooth: hci_bcm: Add wake-up capability") Signed-off-by: Michał Mirosław Signed-off-by: Marcel Holtmann Signed-off-by: Greg Kroah-Hartman --- drivers/bluetooth/hci_bcm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/bluetooth/hci_bcm.c +++ b/drivers/bluetooth/hci_bcm.c @@ -115,6 +115,7 @@ struct bcm_device { u32 oper_speed; int irq; bool irq_active_low; + bool irq_acquired; #ifdef CONFIG_PM struct hci_uart *hu; @@ -288,6 +289,8 @@ static int bcm_request_irq(struct bcm_da goto unlock; } + bdev->irq_acquired = true; + device_init_wakeup(bdev->dev, true); pm_runtime_set_autosuspend_delay(bdev->dev, @@ -456,7 +459,7 @@ static int bcm_close(struct hci_uart *hu } if (bdev) { - if (IS_ENABLED(CONFIG_PM) && bdev->irq > 0) { + if (IS_ENABLED(CONFIG_PM) && bdev->irq_acquired) { devm_free_irq(bdev->dev, bdev->irq, bdev); device_init_wakeup(bdev->dev, false); pm_runtime_disable(bdev->dev);