Merge branch 'dmi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging
Pull dmi fixes from Jean Delvare. * 'dmi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging: firmware: dmi_scan: Check DMI structure length firmware: dmi: Fix permissions of product_family firmware: dmi_scan: Make dmi_walk and dmi_walk_early return real error codes firmware: dmi_scan: Look for SMBIOS 3 entry point first
This commit is contained in:
commit
cbfb749737
|
@ -47,7 +47,7 @@ DEFINE_DMI_ATTR_WITH_SHOW(product_name, 0444, DMI_PRODUCT_NAME);
|
|||
DEFINE_DMI_ATTR_WITH_SHOW(product_version, 0444, DMI_PRODUCT_VERSION);
|
||||
DEFINE_DMI_ATTR_WITH_SHOW(product_serial, 0400, DMI_PRODUCT_SERIAL);
|
||||
DEFINE_DMI_ATTR_WITH_SHOW(product_uuid, 0400, DMI_PRODUCT_UUID);
|
||||
DEFINE_DMI_ATTR_WITH_SHOW(product_family, 0400, DMI_PRODUCT_FAMILY);
|
||||
DEFINE_DMI_ATTR_WITH_SHOW(product_family, 0444, DMI_PRODUCT_FAMILY);
|
||||
DEFINE_DMI_ATTR_WITH_SHOW(board_vendor, 0444, DMI_BOARD_VENDOR);
|
||||
DEFINE_DMI_ATTR_WITH_SHOW(board_name, 0444, DMI_BOARD_NAME);
|
||||
DEFINE_DMI_ATTR_WITH_SHOW(board_version, 0444, DMI_BOARD_VERSION);
|
||||
|
@ -192,7 +192,7 @@ static void __init dmi_id_init_attr_table(void)
|
|||
ADD_DMI_ATTR(product_version, DMI_PRODUCT_VERSION);
|
||||
ADD_DMI_ATTR(product_serial, DMI_PRODUCT_SERIAL);
|
||||
ADD_DMI_ATTR(product_uuid, DMI_PRODUCT_UUID);
|
||||
ADD_DMI_ATTR(product_family, DMI_PRODUCT_FAMILY);
|
||||
ADD_DMI_ATTR(product_family, DMI_PRODUCT_FAMILY);
|
||||
ADD_DMI_ATTR(board_vendor, DMI_BOARD_VENDOR);
|
||||
ADD_DMI_ATTR(board_name, DMI_BOARD_NAME);
|
||||
ADD_DMI_ATTR(board_version, DMI_BOARD_VERSION);
|
||||
|
|
|
@ -144,7 +144,7 @@ static int __init dmi_walk_early(void (*decode)(const struct dmi_header *,
|
|||
|
||||
buf = dmi_early_remap(dmi_base, orig_dmi_len);
|
||||
if (buf == NULL)
|
||||
return -1;
|
||||
return -ENOMEM;
|
||||
|
||||
dmi_decode_table(buf, decode, NULL);
|
||||
|
||||
|
@ -178,7 +178,7 @@ static void __init dmi_save_ident(const struct dmi_header *dm, int slot,
|
|||
const char *d = (const char *) dm;
|
||||
const char *p;
|
||||
|
||||
if (dmi_ident[slot])
|
||||
if (dmi_ident[slot] || dm->length <= string)
|
||||
return;
|
||||
|
||||
p = dmi_string(dm, d[string]);
|
||||
|
@ -191,13 +191,14 @@ static void __init dmi_save_ident(const struct dmi_header *dm, int slot,
|
|||
static void __init dmi_save_uuid(const struct dmi_header *dm, int slot,
|
||||
int index)
|
||||
{
|
||||
const u8 *d = (u8 *) dm + index;
|
||||
const u8 *d;
|
||||
char *s;
|
||||
int is_ff = 1, is_00 = 1, i;
|
||||
|
||||
if (dmi_ident[slot])
|
||||
if (dmi_ident[slot] || dm->length <= index + 16)
|
||||
return;
|
||||
|
||||
d = (u8 *) dm + index;
|
||||
for (i = 0; i < 16 && (is_ff || is_00); i++) {
|
||||
if (d[i] != 0x00)
|
||||
is_00 = 0;
|
||||
|
@ -228,16 +229,17 @@ static void __init dmi_save_uuid(const struct dmi_header *dm, int slot,
|
|||
static void __init dmi_save_type(const struct dmi_header *dm, int slot,
|
||||
int index)
|
||||
{
|
||||
const u8 *d = (u8 *) dm + index;
|
||||
const u8 *d;
|
||||
char *s;
|
||||
|
||||
if (dmi_ident[slot])
|
||||
if (dmi_ident[slot] || dm->length <= index)
|
||||
return;
|
||||
|
||||
s = dmi_alloc(4);
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
d = (u8 *) dm + index;
|
||||
sprintf(s, "%u", *d & 0x7F);
|
||||
dmi_ident[slot] = s;
|
||||
}
|
||||
|
@ -278,9 +280,13 @@ static void __init dmi_save_devices(const struct dmi_header *dm)
|
|||
|
||||
static void __init dmi_save_oem_strings_devices(const struct dmi_header *dm)
|
||||
{
|
||||
int i, count = *(u8 *)(dm + 1);
|
||||
int i, count;
|
||||
struct dmi_device *dev;
|
||||
|
||||
if (dm->length < 0x05)
|
||||
return;
|
||||
|
||||
count = *(u8 *)(dm + 1);
|
||||
for (i = 1; i <= count; i++) {
|
||||
const char *devname = dmi_string(dm, i);
|
||||
|
||||
|
@ -353,6 +359,9 @@ static void __init dmi_save_extended_devices(const struct dmi_header *dm)
|
|||
const char *name;
|
||||
const u8 *d = (u8 *)dm;
|
||||
|
||||
if (dm->length < 0x0B)
|
||||
return;
|
||||
|
||||
/* Skip disabled device */
|
||||
if ((d[0x5] & 0x80) == 0)
|
||||
return;
|
||||
|
@ -387,7 +396,7 @@ static void __init save_mem_devices(const struct dmi_header *dm, void *v)
|
|||
const char *d = (const char *)dm;
|
||||
static int nr;
|
||||
|
||||
if (dm->type != DMI_ENTRY_MEM_DEVICE)
|
||||
if (dm->type != DMI_ENTRY_MEM_DEVICE || dm->length < 0x12)
|
||||
return;
|
||||
if (nr >= dmi_memdev_nr) {
|
||||
pr_warn(FW_BUG "Too many DIMM entries in SMBIOS table\n");
|
||||
|
@ -649,6 +658,21 @@ void __init dmi_scan_machine(void)
|
|||
if (p == NULL)
|
||||
goto error;
|
||||
|
||||
/*
|
||||
* Same logic as above, look for a 64-bit entry point
|
||||
* first, and if not found, fall back to 32-bit entry point.
|
||||
*/
|
||||
memcpy_fromio(buf, p, 16);
|
||||
for (q = p + 16; q < p + 0x10000; q += 16) {
|
||||
memcpy_fromio(buf + 16, q, 16);
|
||||
if (!dmi_smbios3_present(buf)) {
|
||||
dmi_available = 1;
|
||||
dmi_early_unmap(p, 0x10000);
|
||||
goto out;
|
||||
}
|
||||
memcpy(buf, buf + 16, 16);
|
||||
}
|
||||
|
||||
/*
|
||||
* Iterate over all possible DMI header addresses q.
|
||||
* Maintain the 32 bytes around q in buf. On the
|
||||
|
@ -659,7 +683,7 @@ void __init dmi_scan_machine(void)
|
|||
memset(buf, 0, 16);
|
||||
for (q = p; q < p + 0x10000; q += 16) {
|
||||
memcpy_fromio(buf + 16, q, 16);
|
||||
if (!dmi_smbios3_present(buf) || !dmi_present(buf)) {
|
||||
if (!dmi_present(buf)) {
|
||||
dmi_available = 1;
|
||||
dmi_early_unmap(p, 0x10000);
|
||||
goto out;
|
||||
|
@ -993,7 +1017,8 @@ EXPORT_SYMBOL(dmi_get_date);
|
|||
* @decode: Callback function
|
||||
* @private_data: Private data to be passed to the callback function
|
||||
*
|
||||
* Returns -1 when the DMI table can't be reached, 0 on success.
|
||||
* Returns 0 on success, -ENXIO if DMI is not selected or not present,
|
||||
* or a different negative error code if DMI walking fails.
|
||||
*/
|
||||
int dmi_walk(void (*decode)(const struct dmi_header *, void *),
|
||||
void *private_data)
|
||||
|
@ -1001,11 +1026,11 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
|
|||
u8 *buf;
|
||||
|
||||
if (!dmi_available)
|
||||
return -1;
|
||||
return -ENXIO;
|
||||
|
||||
buf = dmi_remap(dmi_base, dmi_len);
|
||||
if (buf == NULL)
|
||||
return -1;
|
||||
return -ENOMEM;
|
||||
|
||||
dmi_decode_table(buf, decode, private_data);
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ static inline int dmi_name_in_vendors(const char *s) { return 0; }
|
|||
static inline int dmi_name_in_serial(const char *s) { return 0; }
|
||||
#define dmi_available 0
|
||||
static inline int dmi_walk(void (*decode)(const struct dmi_header *, void *),
|
||||
void *private_data) { return -1; }
|
||||
void *private_data) { return -ENXIO; }
|
||||
static inline bool dmi_match(enum dmi_field f, const char *str)
|
||||
{ return false; }
|
||||
static inline void dmi_memdev_name(u16 handle, const char **bank,
|
||||
|
|
Loading…
Reference in New Issue