diff options
author | Johan Hovold <johan@kernel.org> | 2021-12-22 11:42:13 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-12-22 13:59:33 +0100 |
commit | 67e532a42cf4c6c214ed39e33e617bca29508f4e (patch) | |
tree | df74967fab29bc13680e3be80a47680d3b125e41 /drivers/base | |
parent | 45e3a279841f13243c45928d7ec2e67d56b37067 (diff) | |
download | linux-stable-67e532a42cf4c6c214ed39e33e617bca29508f4e.tar.gz linux-stable-67e532a42cf4c6c214ed39e33e617bca29508f4e.tar.bz2 linux-stable-67e532a42cf4c6c214ed39e33e617bca29508f4e.zip |
driver core: platform: document registration-failure requirement
Add an explicit comment to document that the reference initialised by
platform_device_register() needs to be released by a call to
platform_device_put() also when registration fails (cf.
device_register()).
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20211222104213.5673-1-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/platform.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 7109351366c8..6cb04ac48bf0 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -763,6 +763,10 @@ EXPORT_SYMBOL_GPL(platform_device_del); /** * platform_device_register - add a platform-level device * @pdev: platform device we're adding + * + * NOTE: _Never_ directly free @pdev after calling this function, even if it + * returned an error! Always use platform_device_put() to give up the + * reference initialised in this function instead. */ int platform_device_register(struct platform_device *pdev) { |