Skip to content

Commit 67e532a

Browse files
jhovoldgregkh
authored andcommitted
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>
1 parent 45e3a27 commit 67e532a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/base/platform.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,10 @@ EXPORT_SYMBOL_GPL(platform_device_del);
763763
/**
764764
* platform_device_register - add a platform-level device
765765
* @pdev: platform device we're adding
766+
*
767+
* NOTE: _Never_ directly free @pdev after calling this function, even if it
768+
* returned an error! Always use platform_device_put() to give up the
769+
* reference initialised in this function instead.
766770
*/
767771
int platform_device_register(struct platform_device *pdev)
768772
{

0 commit comments

Comments
 (0)