From patchwork Fri Apr 14 14:00:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 83421 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp409596vqo; Fri, 14 Apr 2023 07:07:53 -0700 (PDT) X-Google-Smtp-Source: AKy350YRcYoJ9zjN5vybFcP37xaIGwyVZD0XdZQ8IaWwPkFhANyW2brUbJFaO8JSORtvYliIYih6 X-Received: by 2002:aa7:888f:0:b0:628:1274:4d60 with SMTP id z15-20020aa7888f000000b0062812744d60mr9038451pfe.21.1681481272631; Fri, 14 Apr 2023 07:07:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681481272; cv=none; d=google.com; s=arc-20160816; b=WAiLsjH29gdut9m1feFFK9pxSy1dlf7HmEw0m3IV7/Y0QS9Jw3fUCIW2lm+FkjGZXl wCQbzBVMGMkI5c8IbhPH6wLb8OdO9ZVN040GMJcge+E7A/Ornw/5nO29qEQth8qdpoxi 7VUiDYnAlMTyeghMv4iOU5udsawDYQwBmHOulx44ALbUawc2ll0XjWPt9+uU1Vltv5mQ KxCGXJq8OCkpyd53XlKVcQ7s+JWbv4cZCazHjCm6FNV4WFCdWN7ljdQJDU8zJiHBEA52 Fu/CEuLJiW7wRVixxjGAAhTU6mOUlhxMBSAOaPgHA6ISOMAbnPuvEdKoglIC+4tSz3cx DFNQ== 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:cc:to:from; bh=xvOxnLb9YOaY1QRe0cpFg5tB+I0EnJ9OPuOhc5Jge60=; b=cxdW1TN6C4+mtsXKkl2UCUPSFYXXPhMeoxlBBEeuwRhdhOww6BhASy0zJnnP/xafVn IJG2QM6tJj4ckSMFjWdpg3IbT+zjJd1EY+ORKLRQqCye4QJTE6GJgA4dTYzoRZCfH6wn FDoA1QWeSShI9VneGwzyOOptgdOurIyXK52pJifRCQpjhyylxLSV1oTEPBtm34s7FUfa mHtAR0wqOHZX3W4vrLFABG16+k/MqveG/CM+OB5ip1b8dxNhV0YvMsQR0OVrtdHQ9DvC v5Ta15jOoSRR6qm+blrHGQOOhcIkE2vm9iwQq91PnpDa4gWyJp2xqI6/PCb41QKWvMB+ AegA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i30-20020a63585e000000b0050bea56f69asi4808411pgm.735.2023.04.14.07.07.38; Fri, 14 Apr 2023 07:07:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230182AbjDNOBs (ORCPT + 99 others); Fri, 14 Apr 2023 10:01:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230137AbjDNOBl (ORCPT ); Fri, 14 Apr 2023 10:01:41 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95FABB440; Fri, 14 Apr 2023 07:01:16 -0700 (PDT) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.1.0) id 6fe70f731cfbdbc4; Fri, 14 Apr 2023 16:00:49 +0200 Received: from kreacher.localnet (unknown [213.134.188.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id CD86681B369; Fri, 14 Apr 2023 16:00:48 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Hans de Goede Subject: [PATCH v1] ACPI: bus: Ensure that notify handlers are not running after removal Date: Fri, 14 Apr 2023 16:00:48 +0200 Message-ID: <5688433.DvuYhMxLoT@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 213.134.188.177 X-CLIENT-HOSTNAME: 213.134.188.177 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrvdeltddgjedtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepffffffekgfehheffleetieevfeefvefhleetjedvvdeijeejledvieehueevueffnecukfhppedvudefrddufeegrddukeekrddujeejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvddufedrudefgedrudekkedrudejjedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepfedprhgtphhtthhopehlihhnuhigqdgrtghpihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehhuggvghhovgguvgesrhgvughhrghtrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=3 Fuz1=3 Fuz2=3 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763160906947668438?= X-GMAIL-MSGID: =?utf-8?q?1763160906947668438?= From: Rafael J. Wysocki Currently, acpi_device_remove_notify_handler() may return while the notify handler being removed is still running which may allow the module holding that handler to be torn down prematurely. Address this issue by making acpi_device_remove_notify_handler() wait for the handling of all the ACPI events in progress to complete before returning. Fixes: 5894b0c46e49 ("ACPI / scan: Move bus operations and notification routines to bus.c") Signed-off-by: Rafael J. Wysocki --- drivers/acpi/bus.c | 1 + 1 file changed, 1 insertion(+) Index: linux-pm/drivers/acpi/bus.c =================================================================== --- linux-pm.orig/drivers/acpi/bus.c +++ linux-pm/drivers/acpi/bus.c @@ -589,6 +589,7 @@ static void acpi_device_remove_notify_ha acpi_remove_notify_handler(device->handle, type, acpi_notify_device); } + acpi_os_wait_events_complete(); } /* Handle events targeting \_SB device (at present only graceful shutdown) */