1
0
Fork 0

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>
hifive-unleashed-5.1
Arvind Yadav 2018-03-08 15:27:37 +05:30 committed by Thierry Reding
parent 8422c7439e
commit 8bbf5b4261
1 changed files with 2 additions and 1 deletions

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