Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3401799imm; Sun, 30 Sep 2018 20:02:18 -0700 (PDT) X-Google-Smtp-Source: ACcGV6101CwjYnitGddV6xQ+aVe8muImogKbjG9lccZvpmxKIkmwWVwGtAxsphjKPhfHj1HGx7WF X-Received: by 2002:a17:902:7043:: with SMTP id h3-v6mr9729258plt.103.1538362938083; Sun, 30 Sep 2018 20:02:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538362938; cv=none; d=google.com; s=arc-20160816; b=KvhUIFir7mFCh7OWIww41+QHjESlwxvAWQ6sQ5A5EWxJvPhKUYRVQrPTaZMFO95hrQ 07btEmRfaFFVg4YCsTYQsVtVUvwNgYPX2TkDjwaSZgz/FGre2/mA2+nPTH4g0zxTBoSk 4q4L4H6gyoes5/dAyS7+ul05dSKDS3RbNJ4AiUxOqM37Ofn52VGBaoY1w57cfWQWiHoe cTrVbARqVpGnelL+JBxWuRk7J1S9MsPPFabQ/IJwzAUVIkl9QX6qxHRd+gg0kic8ELh7 RdUo9o5/BOMN05yjFUVPr0nHzG3pwetth3tDYFxVtX7mApE26jnsXH1ILCf+IQMIMaU0 0kjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-transfer-encoding :content-disposition:mime-version:message-id:subject:cc:to:from:date; bh=bsYdFkF/iGXwzGLB+5kMbTk5e1Z/NzPUTtR8u+7TAkc=; b=xHdkS/QrF/I4M9e5kUuzICi9kpx8YwBlPnJBI2JfvuWrFBpfnn/slJ/Q2b57i/DFoZ CXZGjZ4d0ZWlu4OmGmZlKgUjb8YZ5zUxVVXy218AISR4FXfq9FL/dzJHjp1BKrmh8BpA ZLUCQHRa/Og0uZflQ5T2v0mB6cEhIren1kK/Er030mQG25WdQJ+kVvCEL42nnWshnwKN M8P52Qiz4uAEu3S7f2PLU4QKj0A5rrr6zI/VkQ+r0aAlVLL9+ANIdPUW7d7a0iI1xXVk KvgQmFHWflqCwrLqlSBZ49LsNC3j3N7umhbEqFvSBaLLvBGIXvJHlK8nSOFDc/hFYTVP wa2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f8-v6si11129220pgu.370.2018.09.30.20.02.03; Sun, 30 Sep 2018 20:02:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728651AbeJAJgD (ORCPT + 99 others); Mon, 1 Oct 2018 05:36:03 -0400 Received: from chill.innovation.ch ([216.218.245.220]:60694 "EHLO chill.innovation.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727843AbeJAJgD (ORCPT ); Mon, 1 Oct 2018 05:36:03 -0400 Date: Sun, 30 Sep 2018 19:53:13 -0700 From: Ronald =?iso-8859-1?Q?Tschal=E4r?= To: "Rafael J. Wysocki" , Len Brown Cc: Zhang Rui , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ACPI/sbshc: Fix rare oops when removing modules. Message-ID: <20181001025313.GA9144@innovation.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.17.1