Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

regulator: Call of_node_put() only once in rzg2l_usb_vbus_regulator_probe()

An of_node_put(config.of_node) call was immediately used after a pointer
check for a devm_regulator_register() call in this function implementation.
Thus call such a function only once instead directly before the check.

This issue was transformed by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Link: https://patch.msgid.link/f9d7a026-a67a-4164-80f4-578b1fbf71ac@web.de
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Markus Elfring and committed by
Mark Brown
7368e9f4 f4e06afb

+2 -5
+2 -5
drivers/regulator/renesas-usb-vbus-regulator.c
··· 49 49 return dev_err_probe(dev, -ENODEV, "regulator node not found\n"); 50 50 51 51 rdev = devm_regulator_register(dev, &rzg2l_usb_vbus_rdesc, &config); 52 - if (IS_ERR(rdev)) { 53 - of_node_put(config.of_node); 52 + of_node_put(config.of_node); 53 + if (IS_ERR(rdev)) 54 54 return dev_err_probe(dev, PTR_ERR(rdev), 55 55 "not able to register vbus regulator\n"); 56 - } 57 - 58 - of_node_put(config.of_node); 59 56 60 57 return 0; 61 58 }