regulator: plug of_node leak in regulator_register()'s error path
authorMichał Mirosław <mirq-linux@rere.qmqm.pl>
Wed, 12 Aug 2020 01:31:36 +0000 (03:31 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Sep 2020 11:55:41 +0000 (13:55 +0200)
commite6724a64b9425c9dc45a4be993fb61ea4d0f2065
treea864561e3357760c46ca5d962330d1d7254a1a8f
parent6828c2aae0b725f01bf2a4b1e4a8d4ec71098ce0
regulator: plug of_node leak in regulator_register()'s error path

commit d3c731564e09b6c2ebefcd1344743a91a237d6dc upstream.

By calling device_initialize() earlier and noting that kfree(NULL) is
ok, we can save a bit of code in error handling and plug of_node leak.
Fixed commit already did part of the work.

Fixes: 9177514ce349 ("regulator: fix memory leak on error path of regulator_register()")
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Reviewed-by: Vladimir Zapolskiy <vz@mleia.com>
Acked-by: Vladimir Zapolskiy <vz@mleia.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/f5035b1b4d40745e66bacd571bbbb5e4644d21a1.1597195321.git.mirq-linux@rere.qmqm.pl
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/regulator/core.c