Commit ed4b197d authored by Colin Ian King's avatar Colin Ian King Committed by Rafael J. Wysocki

ACPI / EC: Free saved_ec on error exit path

Smatch detected two memory leaks on saved_ec:

drivers/acpi/ec.c:1070 acpi_ec_ecdt_probe() warn: possible
  memory leak of 'saved_ec'
drivers/acpi/ec.c:1109 acpi_ec_ecdt_probe() warn: possible
  memory leak of 'saved_ec'

Free saved_ec on these two error exit paths to stop the memory
leak.  Note that saved_ec maybe null, but kfree on null is allowed.
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Acked-by: default avatarLan Tianyu <tianyu.lan@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent dd43de20
...@@ -1069,8 +1069,10 @@ int __init acpi_ec_ecdt_probe(void) ...@@ -1069,8 +1069,10 @@ int __init acpi_ec_ecdt_probe(void)
/* fall through */ /* fall through */
} }
if (EC_FLAGS_SKIP_DSDT_SCAN) if (EC_FLAGS_SKIP_DSDT_SCAN) {
kfree(saved_ec);
return -ENODEV; return -ENODEV;
}
/* This workaround is needed only on some broken machines, /* This workaround is needed only on some broken machines,
* which require early EC, but fail to provide ECDT */ * which require early EC, but fail to provide ECDT */
...@@ -1108,6 +1110,7 @@ int __init acpi_ec_ecdt_probe(void) ...@@ -1108,6 +1110,7 @@ int __init acpi_ec_ecdt_probe(void)
} }
error: error:
kfree(boot_ec); kfree(boot_ec);
kfree(saved_ec);
boot_ec = NULL; boot_ec = NULL;
return -ENODEV; return -ENODEV;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment