Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754253AbbGFSBu (ORCPT ); Mon, 6 Jul 2015 14:01:50 -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 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 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1201 Lines: 42 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; } /** -- 2.4.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/