Re: [PATCH 4/8] DMI: Parse memory device (type 17) in SMBIOS

From: Borislav Petkov
Date: Fri Oct 11 2013 - 11:41:03 EST


On Fri, Oct 11, 2013 at 02:32:42AM -0400, Chen, Gong wrote:
> This patch adds a new interface to decode memory device (type 17)
> to help error reporting on DIMMs.
>
> Original-author: Tony Luck <tony.luck@xxxxxxxxx>
> Signed-off-by: Chen, Gong <gong.chen@xxxxxxxxxxxxxxx>

Reviewed-by: Borislav Petkov <bp@xxxxxxx>

Just a question below:

> ---
> arch/ia64/kernel/setup.c | 1 +
> arch/x86/kernel/setup.c | 1 +
> drivers/firmware/dmi_scan.c | 60 +++++++++++++++++++++++++++++++++++++++++++++
> include/linux/dmi.h | 5 ++++
> 4 files changed, 67 insertions(+)
>

[ ... ]

> diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
> index fa0affb..ca3619d 100644
> --- a/drivers/firmware/dmi_scan.c
> +++ b/drivers/firmware/dmi_scan.c
> @@ -25,6 +25,13 @@ static int dmi_initialized;
> /* DMI system identification string used during boot */
> static char dmi_ids_string[128] __initdata;
>
> +static struct dmi_memdev_info {
> + const char *device;
> + const char *bank;
> + u16 handle;
> +} *dmi_memdev;
> +static int dmi_memdev_nr;
> +
> static const char * __init dmi_string_nosave(const struct dmi_header *dm, u8 s)
> {
> const u8 *bp = ((u8 *) dm) + dm->length;
> @@ -322,6 +329,42 @@ static void __init dmi_save_extended_devices(const struct dmi_header *dm)
> dmi_save_one_device(*d & 0x7f, dmi_string_nosave(dm, *(d - 1)));
> }
>
> +static void __init count_mem_devices(const struct dmi_header *dm, void *v)
> +{
> + if (dm->type != DMI_ENTRY_MEM_DEVICE)
> + return;
> + dmi_memdev_nr++;
> +}
> +
> +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)
> + return;
> + if (nr >= dmi_memdev_nr) {
> + pr_warn_once("Too many DIMM entries in SMBIOS table\n");
> + return;

Is this and count_mem_devices() some sort of precaution against insane
DMI tables?

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/