Merge branch 'dmi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvar...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 13 Apr 2018 23:32:16 +0000 (16:32 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 13 Apr 2018 23:32:16 +0000 (16:32 -0700)
Pull dmi updates from Jean Delvare.

* 'dmi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging:
  firmware: dmi_scan: Use lowercase letters for UUID
  firmware: dmi_scan: Add DMI_OEM_STRING support to dmi_matches
  firmware: dmi_scan: Fix UUID length safety check

1  2 
drivers/firmware/dmi_scan.c

index 6feeacbe4d9784aa3bfaa742da5a46660b78fd34,16dd5ca212c61a2e0e1f76ea4e34f3038f98d1e8..54e66adef2525179e49ecfe9fc04e253ecc18e51
@@@ -32,7 -32,6 +32,7 @@@ static char dmi_ids_string[128] __initd
  static struct dmi_memdev_info {
        const char *device;
        const char *bank;
 +      u64 size;               /* bytes */
        u16 handle;
  } *dmi_memdev;
  static int dmi_memdev_nr;
@@@ -187,7 -186,7 +187,7 @@@ static void __init dmi_save_uuid(const 
        char *s;
        int is_ff = 1, is_00 = 1, i;
  
-       if (dmi_ident[slot] || dm->length <= index + 16)
+       if (dmi_ident[slot] || dm->length < index + 16)
                return;
  
        d = (u8 *) dm + index;
         * says that this is the defacto standard.
         */
        if (dmi_ver >= 0x020600)
-               sprintf(s, "%pUL", d);
+               sprintf(s, "%pUl", d);
        else
-               sprintf(s, "%pUB", d);
+               sprintf(s, "%pUb", d);
  
        dmi_ident[slot] = s;
  }
@@@ -387,8 -386,6 +387,8 @@@ static void __init save_mem_devices(con
  {
        const char *d = (const char *)dm;
        static int nr;
 +      u64 bytes;
 +      u16 size;
  
        if (dm->type != DMI_ENTRY_MEM_DEVICE || dm->length < 0x12)
                return;
        dmi_memdev[nr].handle = get_unaligned(&dm->handle);
        dmi_memdev[nr].device = dmi_string(dm, d[0x10]);
        dmi_memdev[nr].bank = dmi_string(dm, d[0x11]);
 +
 +      size = get_unaligned((u16 *)&d[0xC]);
 +      if (size == 0)
 +              bytes = 0;
 +      else if (size == 0xffff)
 +              bytes = ~0ull;
 +      else if (size & 0x8000)
 +              bytes = (u64)(size & 0x7fff) << 10;
 +      else if (size != 0x7fff)
 +              bytes = (u64)size << 20;
 +      else
 +              bytes = (u64)get_unaligned((u32 *)&d[0x1C]) << 20;
 +
 +      dmi_memdev[nr].size = bytes;
        nr++;
  }
  
@@@ -792,7 -775,15 +792,15 @@@ static bool dmi_matches(const struct dm
                int s = dmi->matches[i].slot;
                if (s == DMI_NONE)
                        break;
-               if (dmi_ident[s]) {
+               if (s == DMI_OEM_STRING) {
+                       /* DMI_OEM_STRING must be exact match */
+                       const struct dmi_device *valid;
+                       valid = dmi_find_device(DMI_DEV_TYPE_OEM_STRING,
+                                               dmi->matches[i].substr, NULL);
+                       if (valid)
+                               continue;
+               } else if (dmi_ident[s]) {
                        if (dmi->matches[i].exact_match) {
                                if (!strcmp(dmi_ident[s],
                                            dmi->matches[i].substr))
  }
  EXPORT_SYMBOL(dmi_get_date);
  
 +/**
 + *    dmi_get_bios_year - get a year out of DMI_BIOS_DATE field
 + *
 + *    Returns year on success, -ENXIO if DMI is not selected,
 + *    or a different negative error code if DMI field is not present
 + *    or not parseable.
 + */
 +int dmi_get_bios_year(void)
 +{
 +      bool exists;
 +      int year;
 +
 +      exists = dmi_get_date(DMI_BIOS_DATE, &year, NULL, NULL);
 +      if (!exists)
 +              return -ENODATA;
 +
 +      return year ? year : -ERANGE;
 +}
 +EXPORT_SYMBOL(dmi_get_bios_year);
 +
  /**
   *    dmi_walk - Walk the DMI table and get called back for every record
   *    @decode: Callback function
@@@ -1102,17 -1073,3 +1110,17 @@@ void dmi_memdev_name(u16 handle, const 
        }
  }
  EXPORT_SYMBOL_GPL(dmi_memdev_name);
 +
 +u64 dmi_memdev_size(u16 handle)
 +{
 +      int n;
 +
 +      if (dmi_memdev) {
 +              for (n = 0; n < dmi_memdev_nr; n++) {
 +                      if (handle == dmi_memdev[n].handle)
 +                              return dmi_memdev[n].size;
 +              }
 +      }
 +      return ~0ull;
 +}
 +EXPORT_SYMBOL_GPL(dmi_memdev_size);