software node: Free resources explicitly when swnode_register() fails
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 29 Mar 2021 15:12:02 +0000 (18:12 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 5 Apr 2021 11:18:21 +0000 (13:18 +0200)
commit3f6b6536a73fad0c2c82db1672fc500cc15ff551
tree4885e84c2d77175cd06385036628d06a47762182
parentc8a9c285f136f0cc65ac8328cd1710b155ad3df8
software node: Free resources explicitly when swnode_register() fails

Currently we have a slightly twisted logic in swnode_register().
It frees resources that it doesn't allocate on error path and
in once case it relies on the ->release() implementation.

Untwist the logic by freeing resources explicitly when swnode_register()
fails. Currently it happens only in fwnode_create_software_node().

Tested-by: Daniel Scally <djrscally@gmail.com>
Reviewed-by: Daniel Scally <djrscally@gmail.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210329151207.36619-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/swnode.c