* [PATCH] regulator: core: Clear constraints pointer after free on error path
@ 2016-01-26 15:14 Charles Keepax
2016-01-26 15:34 ` Mark Brown
0 siblings, 1 reply; 3+ messages in thread
From: Charles Keepax @ 2016-01-26 15:14 UTC (permalink / raw)
To: broonie; +Cc: lgirdwood, linux-kernel, patches
As we now free the constraints in regulator_dev_release we will still
call free on the constraints pointer even if we went down an error path
in regulator_register, as such we need to clear to the pointer to ensure
the kfree in regulator_dev_release is a no-op.
Fixes: 29f5f4860a8e ("regulator: core: Move more deallocation into class unregister")
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
drivers/regulator/core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 744c988..a7936ab 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -3980,6 +3980,7 @@ unset_supplies:
scrub:
regulator_ena_gpio_free(rdev);
kfree(rdev->constraints);
+ rdev->constraints = NULL;
wash:
device_unregister(&rdev->dev);
/* device core frees rdev */
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] regulator: core: Clear constraints pointer after free on error path
2016-01-26 15:14 [PATCH] regulator: core: Clear constraints pointer after free on error path Charles Keepax
@ 2016-01-26 15:34 ` Mark Brown
2016-01-26 15:57 ` Charles Keepax
0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2016-01-26 15:34 UTC (permalink / raw)
To: Charles Keepax; +Cc: lgirdwood, linux-kernel, patches
[-- Attachment #1: Type: text/plain, Size: 494 bytes --]
On Tue, Jan 26, 2016 at 03:14:16PM +0000, Charles Keepax wrote:
> As we now free the constraints in regulator_dev_release we will still
> call free on the constraints pointer even if we went down an error path
> in regulator_register, as such we need to clear to the pointer to ensure
> the kfree in regulator_dev_release is a no-op.
No, this is just making things worse - if we're doing the free in the
release we should be doing the free in the release not sometimes maybey
in the release.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] regulator: core: Clear constraints pointer after free on error path
2016-01-26 15:34 ` Mark Brown
@ 2016-01-26 15:57 ` Charles Keepax
0 siblings, 0 replies; 3+ messages in thread
From: Charles Keepax @ 2016-01-26 15:57 UTC (permalink / raw)
To: Mark Brown; +Cc: lgirdwood, linux-kernel, patches
On Tue, Jan 26, 2016 at 03:34:54PM +0000, Mark Brown wrote:
> On Tue, Jan 26, 2016 at 03:14:16PM +0000, Charles Keepax wrote:
>
> > As we now free the constraints in regulator_dev_release we will still
> > call free on the constraints pointer even if we went down an error path
> > in regulator_register, as such we need to clear to the pointer to ensure
> > the kfree in regulator_dev_release is a no-op.
>
> No, this is just making things worse - if we're doing the free in the
> release we should be doing the free in the release not sometimes maybey
> in the release.
Fair enough I will respin to remove the other free's.
Thanks,
Charles
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-01-26 15:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-26 15:14 [PATCH] regulator: core: Clear constraints pointer after free on error path Charles Keepax
2016-01-26 15:34 ` Mark Brown
2016-01-26 15:57 ` Charles Keepax
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox