linux-imx/drivers/firmware
Jean Delvare 8d4bc4c9b7 firmware: dmi_scan: Fix handling of empty DMI strings
commit a7770ae194 upstream.

The handling of empty DMI strings looks quite broken to me:
* Strings from 1 to 7 spaces are not considered empty.
* True empty DMI strings (string index set to 0) are not considered
  empty, and result in allocating a 0-char string.
* Strings with invalid index also result in allocating a 0-char
  string.
* Strings starting with 8 spaces are all considered empty, even if
  non-space characters follow (sounds like a weird thing to do, but
  I have actually seen occurrences of this in DMI tables before.)
* Strings which are considered empty are reported as 8 spaces,
  instead of being actually empty.

Some of these issues are the result of an off-by-one error in memcmp,
the rest is incorrect by design.

So let's get it square: missing strings and strings made of only
spaces, regardless of their length, should be treated as empty and
no memory should be allocated for them. All other strings are
non-empty and should be allocated.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Fixes: 79da472111 ("x86: fix DMI out of memory problems")
Cc: Parag Warudkar <parag.warudkar@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2018-06-01 00:30:12 +01:00
..
google drivers/firmware: Add module.h to google/gsmi.c 2011-10-31 19:31:46 -04:00
dcdbas.c dcdbas: force SMI to happen when expected 2011-03-02 13:42:10 +01:00
dcdbas.h dcdbas: export functionality for use in other drivers 2009-01-08 08:31:12 -08:00
dell_rbu.c sysfs: add struct file* to bin_attr callbacks 2010-05-21 09:37:31 -07:00
dmi_scan.c firmware: dmi_scan: Fix handling of empty DMI strings 2018-06-01 00:30:12 +01:00
dmi-id.c dmi-id: fix a memory leak in dmi_id_init error path 2010-08-05 13:53:34 -07:00
dmi-sysfs.c firmware: Fix unaligned memory accesses in dmi-sysfs 2011-02-25 16:10:03 -08:00
edd.c [SCSI] edd: Treat "XPRS" host bus type the same as "PCI" 2011-10-31 13:26:19 +04:00
efivars.c x86, efivars: firmware bug workarounds should be in platform code 2013-05-30 14:35:10 +01:00
iscsi_ibft_find.c efi: Make 'efi_enabled' a function to query EFI facilities 2013-02-06 04:33:50 +00:00
iscsi_ibft.c ibft: Fix finding IBFT ACPI table on UEFI 2011-12-13 09:08:31 -05:00
Kconfig efivars: Add module parameter to disable use as a pstore backend 2013-03-27 02:41:20 +00:00
Makefile Introduce CONFIG_GOOGLE_FIRMWARE 2011-04-29 18:09:35 -07:00
memmap.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
pcdp.c pcdp: use early_ioremap/early_iounmap to access pcdp table 2012-08-10 00:25:00 +01:00
pcdp.h Update broken web addresses in the kernel. 2010-10-18 11:03:14 +02:00
sigma.c firmware: Sigma: Fix endianess issues 2011-11-29 11:59:50 +00:00