Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8bbf5b42 authored by Arvind Yadav's avatar Arvind Yadav Committed by Thierry Reding
Browse files

pwm: sysfs: Use put_device() instead of kfree()



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: default avatarArvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
parent 8422c743
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -273,7 +273,8 @@ static int pwm_export_child(struct device *parent, struct pwm_device *pwm)
	ret = device_register(&export->child);
	ret = device_register(&export->child);
	if (ret) {
	if (ret) {
		clear_bit(PWMF_EXPORTED, &pwm->flags);
		clear_bit(PWMF_EXPORTED, &pwm->flags);
		kfree(export);
		put_device(&export->child);
		export = NULL;
		return ret;
		return ret;
	}
	}