]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/acpi/custom_method.c
ACPI: custom_method: fix memory leaks
[mirror_ubuntu-bionic-kernel.git] / drivers / acpi / custom_method.c
index b33fba70ec51708a19fe59fc490b79f27f4de8f5..9dc745458739ad5d1aad29fb05d18fc3bd8c6e3d 100644 (file)
@@ -51,8 +51,10 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf,
        if ((*ppos > max_size) ||
            (*ppos + count > max_size) ||
            (*ppos + count < count) ||
-           (count > uncopied_bytes))
+           (count > uncopied_bytes)) {
+               kfree(buf);
                return -EINVAL;
+       }
 
        if (copy_from_user(buf + (*ppos), user_buf, count)) {
                kfree(buf);
@@ -72,6 +74,7 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf,
                add_taint(TAINT_OVERRIDDEN_ACPI_TABLE, LOCKDEP_NOW_UNRELIABLE);
        }
 
+       kfree(buf);
        return count;
 }