Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp613626img; Fri, 22 Mar 2019 05:10:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqy9tJ3Xxop3zlfsw9rjGokO7ltC+Gj445yWRZL7o/6Qou9hD/MLVvqtVLx+lvVapLp0+7Vr X-Received: by 2002:a62:4649:: with SMTP id t70mr9123344pfa.100.1553256638113; Fri, 22 Mar 2019 05:10:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553256638; cv=none; d=google.com; s=arc-20160816; b=wyBuqBYIIExrVvehaOQSgRoMJlIAZ0vez71+iwfEDq80bN0rUPYTiu6zvNJG2iec4W GbKCz0TY/AkPtdh3wusaK1HyMu4uIg5r+q4Ddby/o56c2/13Tt3aJRGkqv8jbKAZ9BSl h62yVUXpVpBiSUFBF7m2blrUt3gfdo16y+1VuSwm20u6cJTeIidjOTOOc0rMqI80ScBL A8ykmZovkatRInb31cPDoxxi45lWONlBSZ6DIUQBznFoJjxvq4b4RavUf0emMyIEj3cI O56Cbj5hSdC4DB1KtmwaKmxsH3ytuGQCn3THJqCEWtELMMUEmyLiDI+KZXa4YQ7B5TnJ cI7w== 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=/7DPbJPnXYrT1AG7Ycrlyw7Dw3FJeCGxNyyO1GifX4Y=; b=OUswB/d+C2vOCmMUiwksSTtWODm+L0LRKb7ePditp5WLMy7cmkFNsv+4WSDIs+e7B6 59ZczeRFfQOWtKKnvPg6p/nmjNRsJqhe6JRL2CCcWFX04zk9vTcXVxhcXMy0SF0koaYR gi6+UNz2Pb2mzXvyiBbslOG4MduK2eKC8/np3vMI5idwptcA6DQFGm6SoGmzk+MgexvK FLBa7w7ixm6Y6+1Y18sLBgamtDhE8c976x1AxkKRjus2JCVwpuTzXRiyhR+p/0BflpB2 JKipDhd/SsCsjN93uSaNWMWM6sEoffEx4Q6MOKaWqp0qRoAj4yuZmeo5F4dUaW6NoVMI tMvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="y5w4ds/W"; 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 w3si6729216pll.417.2019.03.22.05.10.20; Fri, 22 Mar 2019 05:10:38 -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; dkim=pass header.i=@kernel.org header.s=default header.b="y5w4ds/W"; 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 S2389293AbfCVMJU (ORCPT + 99 others); Fri, 22 Mar 2019 08:09:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:47756 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388535AbfCVMJS (ORCPT ); Fri, 22 Mar 2019 08:09:18 -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 778B120830; Fri, 22 Mar 2019 12:09:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553256558; bh=g0FUaRzX/hlLZxbKl2FnEnyOoA9cgDaNFtlunLsP/r8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y5w4ds/W90ZYZWHTxZfj7F7ukxcp2KLNHrC9CJU06IBhilS87mL6vpKtggS4w/wc3 WE5RWvcxiWdbC7I2NfJEigHw5j4gtyv8sWswG0QKj4QUWrROSctewPdBZnSK18ARSm 4G4idcB8vsDkGXA1xKT8Cdfk7dpD7h+R8irrAEcI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Viresh Kumar , "Rafael J. Wysocki" Subject: [PATCH 4.19 248/280] PM / wakeup: Rework wakeup source timer cancellation Date: Fri, 22 Mar 2019 12:16:41 +0100 Message-Id: <20190322111340.917105633@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111306.356185024@linuxfoundation.org> References: <20190322111306.356185024@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Viresh Kumar commit 1fad17fb1bbcd73159c2b992668a6957ecc5af8a upstream. If wakeup_source_add() is called right after wakeup_source_remove() for the same wakeup source, timer_setup() may be called for a potentially scheduled timer which is incorrect. To avoid that, move the wakeup source timer cancellation from wakeup_source_drop() to wakeup_source_remove(). Moreover, make wakeup_source_remove() clear the timer function after canceling the timer to let wakeup_source_not_registered() treat unregistered wakeup sources in the same way as the ones that have never been registered. Signed-off-by: Viresh Kumar Cc: 4.4+ # 4.4+ [ rjw: Subject, changelog, merged two patches together ] Signed-off-by: Rafael J. Wysocki Signed-off-by: Greg Kroah-Hartman --- drivers/base/power/wakeup.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/drivers/base/power/wakeup.c +++ b/drivers/base/power/wakeup.c @@ -118,7 +118,6 @@ void wakeup_source_drop(struct wakeup_so if (!ws) return; - del_timer_sync(&ws->timer); __pm_relax(ws); } EXPORT_SYMBOL_GPL(wakeup_source_drop); @@ -205,6 +204,13 @@ void wakeup_source_remove(struct wakeup_ list_del_rcu(&ws->entry); raw_spin_unlock_irqrestore(&events_lock, flags); synchronize_srcu(&wakeup_srcu); + + del_timer_sync(&ws->timer); + /* + * Clear timer.function to make wakeup_source_not_registered() treat + * this wakeup source as not registered. + */ + ws->timer.function = NULL; } EXPORT_SYMBOL_GPL(wakeup_source_remove);