Re: [PATCH 2/4] dmi: Add a DMI firmware node and handling

From: Jean Delvare
Date: Mon Feb 01 2016 - 04:25:30 EST


Hi Corey,

I won't comment on the IPMI side of this as this isn't my area. However
I have a comment on the DMI part:

Le Friday 29 January 2016 Ã 16:43 -0600, minyard@xxxxxxx a Ãcrit :
> From: Corey Minyard <cminyard@xxxxxxxxxx>
>
> This is so that an IPMI platform device can be created from a
> DMI firmware entry.
>
> Signed-off-by: Corey Minyard <cminyard@xxxxxxxxxx>
> Cc: Jean Delvare <jdelvare@xxxxxxx>
> Cc: Andy Lutomirski <luto@xxxxxxxxxx>
> ---
> drivers/firmware/dmi_scan.c | 34 ++++++++++++++++++++++++----------
> include/linux/dmi.h | 24 ++++++++++++++++++++++++
> include/linux/fwnode.h | 1 +
> 3 files changed, 49 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
> index da471b2..13d9bca 100644
> --- a/drivers/firmware/dmi_scan.c
> +++ b/drivers/firmware/dmi_scan.c
> @@ -41,6 +41,16 @@ static struct dmi_memdev_info {
> } *dmi_memdev;
> static int dmi_memdev_nr;
>
> +static void *dmi_zalloc(unsigned len)
> +{
> + void *ret = dmi_alloc(len);
> +
> + if (ret)
> + memset(ret, 0, len);
> +
> + return ret;
> +}
> +
> static const char * __init dmi_string_nosave(const struct dmi_header *dm, u8 s)
> {
> const u8 *bp = ((u8 *) dm) + dm->length;
> @@ -242,6 +252,12 @@ static void __init dmi_save_type(const struct dmi_header *dm, int slot,
> (...)
> @@ -250,15 +266,14 @@ static void __init dmi_save_one_device(int type, const char *name)
> if (dmi_find_device(type, name, NULL))
> return;
>
> - dev = dmi_alloc(sizeof(*dev) + strlen(name) + 1);
> + dev = dmi_zalloc(sizeof(*dev) + strlen(name) + 1);
> if (!dev)
> return;
>
> dev->type = type;
> strcpy((char *)(dev + 1), name);
> dev->name = (char *)(dev + 1);
> - dev->device_data = NULL;

This change seems rather unrelated, and I'm not sure what purpose it
serves. On ia64 and arm64 it is clearly redundant as dmi_alloc calls
kzalloc directly. On x86_64, extend_brk is called instead (don't ask me
why, I have no clue) but looking at the code I see that it does
memset(ret, 0, size) as well so memory is also zeroed there. Which makes
dmi_alloc the same as dmi_zalloc on all 3 architectures.

So please revert this change. This will make your patch easier to
review, too.

--
Jean Delvare
SUSE L3 Support