From patchwork Mon Jul 6 18:01:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 6727041 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 31D8CC05AC for ; Mon, 6 Jul 2015 18:02:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5751D2067A for ; Mon, 6 Jul 2015 18:02:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 65F51205D8 for ; Mon, 6 Jul 2015 18:02:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753701AbbGFSBt (ORCPT ); Mon, 6 Jul 2015 14:01:49 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:38449 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752482AbbGFSBs (ORCPT ); Mon, 6 Jul 2015 14:01:48 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id t66I1KBK012833; Mon, 6 Jul 2015 13:01:21 -0500 Received: from DLEE70.ent.ti.com (dlemailx.itg.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id t66I1K6W013254; Mon, 6 Jul 2015 13:01:20 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.224.2; Mon, 6 Jul 2015 13:01:08 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id t66I1JIQ016296; Mon, 6 Jul 2015 13:01:19 -0500 From: Felipe Balbi To: CC: , Tony Lindgren , Linux OMAP Mailing List , Linux ARM Kernel Mailing List , Linux Kernel Mailing List , Felipe Balbi , Tony Lindgren Subject: [PATCH] base: power: wakeirq: don't leak dev->power.wakeirq Date: Mon, 6 Jul 2015 13:01:18 -0500 Message-ID: <1436205678-31640-1-git-send-email-balbi@ti.com> X-Mailer: git-send-email 2.4.4 MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP on a first call to dev_pm_attach_wake_irq(), if it fails, it will leave dev->power.wakeirq set to a dangling pointer. Instead, let's clear it to make sure a subsequent call to dev_pm_attach_wake_irq() has chance to succeed. Cc: Tony Lindgren Signed-off-by: Felipe Balbi --- drivers/base/power/wakeirq.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/wakeirq.c b/drivers/base/power/wakeirq.c index 7470004ca810..394d250a1ad8 100644 --- a/drivers/base/power/wakeirq.c +++ b/drivers/base/power/wakeirq.c @@ -50,9 +50,16 @@ static int dev_pm_attach_wake_irq(struct device *dev, int irq, err = device_wakeup_attach_irq(dev, wirq); if (err) - return err; + goto err_cleanup; return 0; + +err_cleanup: + spin_lock_irqsave(&dev->power.lock, flags); + dev->power.wakeirq = NULL; + spin_unlock_irqrestore(&dev->power.lock, flags); + + return err; } /**