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: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
This commit is contained in:
Arvind Yadav 2018-03-08 15:27:37 +05:30 committed by Thierry Reding
parent 8422c7439e
commit 8bbf5b4261

View File

@ -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;
}