[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <1394721184.20773.15.camel@AMDC1943>
Date: Thu, 13 Mar 2014 15:33:04 +0100
From: Krzysztof Kozlowski <k.kozlowski@...sung.com>
To: Mark Brown <broonie@...nel.org>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] regmap: irq: Set data pointer only on regmap_add_irq_chip
success
On Thu, 2014-03-13 at 14:13 +0000, Mark Brown wrote:
> On Thu, Mar 13, 2014 at 09:06:01AM +0100, Krzysztof Kozlowski wrote:
> > After setting the 'data' pointer (wchich is returned to the caller for
> > freeing later) the regmap_add_irq_chip() could still fail for various
> > reasons (ENOMEM, regmap_read or regmap_write failure). In such case the
> > memory under 'data' was freed in error path and error value was returned
> > but the 'data' variable was not changed.
> >
> > This could lead to errors if the caller passed such 'data' to
> > regmap_del_irq_chip().
>
> If the user is calling regmap_del_irq_chip() after the add failed then
> I'd expect things to break anyway...
Yes, you're right but still I think that 'data' should be set in a
atomic way - only if regmap_add_irq_chip() succeeds. Usually a caller
passing a pointer for allocation expects that one of:
1. Allocation succeeds and it is put under passed pointer;
2. Allocation fails and no one touches my pointer.
Best regards,
Krzysztof
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists