* [PATCH] pwm: sysfs: use put_device() instead of kfree()
@ 2018-03-08 9:57 Arvind Yadav
2018-03-27 23:19 ` Thierry Reding
0 siblings, 1 reply; 2+ messages in thread
From: Arvind Yadav @ 2018-03-08 9:57 UTC (permalink / raw)
To: thierry.reding; +Cc: linux-kernel, linux-pwm
Never directly free @dev after calling device_register(), even
if it returned an error! Always use put_device() to give up the
reference initialized.
Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
drivers/pwm/sysfs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/pwm/sysfs.c b/drivers/pwm/sysfs.c
index 83f2b0b..7c71cdb 100644
--- a/drivers/pwm/sysfs.c
+++ b/drivers/pwm/sysfs.c
@@ -273,7 +273,8 @@ static int pwm_export_child(struct device *parent, struct pwm_device *pwm)
ret = device_register(&export->child);
if (ret) {
clear_bit(PWMF_EXPORTED, &pwm->flags);
- kfree(export);
+ put_device(&export->child);
+ export = NULL;
return ret;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] pwm: sysfs: use put_device() instead of kfree()
2018-03-08 9:57 [PATCH] pwm: sysfs: use put_device() instead of kfree() Arvind Yadav
@ 2018-03-27 23:19 ` Thierry Reding
0 siblings, 0 replies; 2+ messages in thread
From: Thierry Reding @ 2018-03-27 23:19 UTC (permalink / raw)
To: Arvind Yadav; +Cc: linux-kernel, linux-pwm
[-- Attachment #1: Type: text/plain, Size: 406 bytes --]
On Thu, Mar 08, 2018 at 03:27:37PM +0530, Arvind Yadav wrote:
> Never directly free @dev after calling device_register(), even
> if it returned an error! Always use put_device() to give up the
> reference initialized.
>
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> ---
> drivers/pwm/sysfs.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
Applied, thanks.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-27 23:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-08 9:57 [PATCH] pwm: sysfs: use put_device() instead of kfree() Arvind Yadav
2018-03-27 23:19 ` Thierry Reding
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.