Skip to content

Commit

Permalink
pwm: sysfs: Use put_device() instead of kfree()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ArvindYadavCs authored and thierryreding committed Mar 27, 2018
1 parent 8422c74 commit 8bbf5b4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/pwm/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 8bbf5b4

Please sign in to comment.