From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3CF5C00449 for ; Wed, 3 Oct 2018 09:29:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7244C20835 for ; Wed, 3 Oct 2018 09:29:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7244C20835 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727773AbeJCQRE convert rfc822-to-8bit (ORCPT ); Wed, 3 Oct 2018 12:17:04 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:44037 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726724AbeJCQRD (ORCPT ); Wed, 3 Oct 2018 12:17:03 -0400 Received: from 79.184.253.194.ipv4.supernova.orange.pl (79.184.253.194) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.148) id 3776aaf8a60974ad; Wed, 3 Oct 2018 11:29:27 +0200 From: "Rafael J. Wysocki" To: Ronald =?ISO-8859-1?Q?Tschal=E4r?= Cc: Len Brown , Zhang Rui , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ACPI/sbshc: Fix rare oops when removing modules. Date: Wed, 03 Oct 2018 11:26:27 +0200 Message-ID: <6138243.jYEBpdSlFa@aspire.rjw.lan> In-Reply-To: <20181001025313.GA9144@innovation.ch> References: <20181001025313.GA9144@innovation.ch> MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset="iso-8859-1" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday, October 1, 2018 4:53:13 AM CEST Ronald Tschalär wrote: > There was a small race when removing the sbshc module where > smbus_alarm() had queued acpi_smbus_callback() for deferred execution > but it hadn't been run yet, so that when it did run hc had been freed > and the module unloaded, resulting in an invalid paging request. > > A similar race existed when removing the sbs module with regards to > acpi_sbs_callback() (which is called from acpi_smbus_callback()). > > We therefore need to ensure no callbacks are pending or executing before > the cleanups are done and the modules are removed. > > Signed-off-by: Ronald Tschalär > --- > drivers/acpi/osl.c | 1 + > drivers/acpi/sbshc.c | 2 ++ > 2 files changed, 3 insertions(+) > > diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c > index 8df9abfa947b..9d139727f164 100644 > --- a/drivers/acpi/osl.c > +++ b/drivers/acpi/osl.c > @@ -1129,6 +1129,7 @@ void acpi_os_wait_events_complete(void) > flush_workqueue(kacpid_wq); > flush_workqueue(kacpi_notify_wq); > } > +EXPORT_SYMBOL(acpi_os_wait_events_complete); > > struct acpi_hp_work { > struct work_struct work; > diff --git a/drivers/acpi/sbshc.c b/drivers/acpi/sbshc.c > index 7a3431018e0a..5008ead4609a 100644 > --- a/drivers/acpi/sbshc.c > +++ b/drivers/acpi/sbshc.c > @@ -196,6 +196,7 @@ int acpi_smbus_unregister_callback(struct acpi_smb_hc *hc) > hc->callback = NULL; > hc->context = NULL; > mutex_unlock(&hc->lock); > + acpi_os_wait_events_complete(); > return 0; > } > > @@ -292,6 +293,7 @@ static int acpi_smbus_hc_remove(struct acpi_device *device) > > hc = acpi_driver_data(device); > acpi_ec_remove_query_handler(hc->ec, hc->query_bit); > + acpi_os_wait_events_complete(); > kfree(hc); > device->driver_data = NULL; > return 0; > Applied, thanks!