Currently resources aren't freed in the order in which they have been
allocated. Eg probe() frees drvdata->states even if it failed before
allocating that. I think allocating/copying the affacted data structures
isn't necessary anyway, so this is the easiest way to fix this.

Patch 1/2 is the actual fix.
Patch 2/2 is minor cleanup while looking at the code.

This series has only been compile tested yet. I will test it on
device-tree HW when I get access to my test equipment. I can't test
non-device-tree code however.

Other notes:
* This driver passes &drvdata->desc uninitialized (but zeroed) to
  of_get_gpio_regulator_config() - I don't know if this is ok.
* I'm not sure if copying config->supply_name is actually necessary,
  so I left that one in.

Harald Geyer (2):
  regulator: gpio: Avoid unnecessarily copying data structures in
    probe()
  regulator: gpio: Move last remaining memory allocation to devres

 drivers/regulator/gpio-regulator.c | 46 +++++++++-----------------------------
 1 file changed, 10 insertions(+), 36 deletions(-)

-- 
2.1.4

Reply via email to