pwm: sysfs: Use put_device() instead of kfree()
authorArvind Yadav <arvind.yadav.cs@gmail.com>
Thu, 8 Mar 2018 09:57:37 +0000 (15:27 +0530)
committerThierry Reding <thierry.reding@gmail.com>
Tue, 27 Mar 2018 23:18:53 +0000 (01:18 +0200)
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>
drivers/pwm/sysfs.c

index 83f2b0b..7c71cdb 100644 (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;
        }