Merge tag 'acpi-5.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael...
[sfrench/cifs-2.6.git] / drivers / firmware / efi / cper.c
index 6a966ecdd80a1f71149b05e45c676dca2f8f21fc..8fa977c7861f961c32af4dfa3b949e9c5f1460ec 100644 (file)
@@ -534,19 +534,24 @@ EXPORT_SYMBOL_GPL(cper_estatus_check_header);
 int cper_estatus_check(const struct acpi_hest_generic_status *estatus)
 {
        struct acpi_hest_generic_data *gdata;
 int cper_estatus_check(const struct acpi_hest_generic_status *estatus)
 {
        struct acpi_hest_generic_data *gdata;
-       unsigned int data_len, gedata_len;
+       unsigned int data_len, record_size;
        int rc;
 
        rc = cper_estatus_check_header(estatus);
        if (rc)
                return rc;
        int rc;
 
        rc = cper_estatus_check_header(estatus);
        if (rc)
                return rc;
+
        data_len = estatus->data_length;
 
        apei_estatus_for_each_section(estatus, gdata) {
        data_len = estatus->data_length;
 
        apei_estatus_for_each_section(estatus, gdata) {
-               gedata_len = acpi_hest_get_error_length(gdata);
-               if (gedata_len > data_len - acpi_hest_get_size(gdata))
+               if (sizeof(struct acpi_hest_generic_data) > data_len)
+                       return -EINVAL;
+
+               record_size = acpi_hest_get_record_size(gdata);
+               if (record_size > data_len)
                        return -EINVAL;
                        return -EINVAL;
-               data_len -= acpi_hest_get_record_size(gdata);
+
+               data_len -= record_size;
        }
        if (data_len)
                return -EINVAL;
        }
        if (data_len)
                return -EINVAL;