Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752406AbbGGERT (ORCPT ); Tue, 7 Jul 2015 00:17:19 -0400 Received: from mail-ig0-f179.google.com ([209.85.213.179]:36539 "EHLO mail-ig0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751146AbbGGERI (ORCPT ); Tue, 7 Jul 2015 00:17:08 -0400 MIME-Version: 1.0 In-Reply-To: <20150706180921.GF20779@saruman.tx.rr.com> References: <1436205678-31640-1-git-send-email-balbi@ti.com> <20150706180921.GF20779@saruman.tx.rr.com> Date: Tue, 7 Jul 2015 06:17:07 +0200 Message-ID: Subject: Re: [PATCH] base: power: wakeirq: don't leak dev->power.wakeirq From: Michael Trimarchi To: Felipe Balbi Cc: linux-arm-kernel , rjw@rjwysocki.net, Tony Lindgren , Linux Kernel Mailing List , linux-pm@vger.kernel.org, Linux OMAP Mailing List , Tony Lindgren Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2103 Lines: 64 Hi On Mon, Jul 6, 2015 at 8:09 PM, Felipe Balbi wrote: > On Mon, Jul 06, 2015 at 08:06:17PM +0200, Michael Trimarchi wrote: >> Hi >> >> On Jul 6, 2015 8:01 PM, "Felipe Balbi" wrote: >> > >> > 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); >> > + >> >> Why here and not in the fuction that return the error? > > because the field was set here, why would I clear it elsewhere ? > Clear now and even more from the other patch proposal. Michael > -- > balbi -- | Michael Nazzareno Trimarchi Amarula Solutions BV | | COO - Founder Cruquiuskade 47 | | +31(0)851119172 Amsterdam 1018 AM NL | | [`as] http://www.amarulasolutions.com | -- 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/