From: Steve Lin <steven.l...@broadcom.com>
Date: Tue, 24 Oct 2017 16:12:33 -0400

> +     switch (type) {
> +     case NLA_U8:
> +             val = *((u8 *)value);
> +             if (nla_put_u8(msg, DEVLINK_ATTR_PERM_CONFIG_VALUE, val))
> +                     goto nest_err;
> +             break;
> +     case NLA_U16:
> +             val = *((u16 *)value);
> +             if (nla_put_u16(msg, DEVLINK_ATTR_PERM_CONFIG_VALUE, val))
> +                     goto nest_err;
> +             break;
> +     case NLA_U32:
> +             val = *((u32 *)value);
> +             if (nla_put_u32(msg, DEVLINK_ATTR_PERM_CONFIG_VALUE, val))
> +                     goto nest_err;
> +             break;
> +     }
> +     nla_nest_end(msg, param_attr);
> +
> +     kfree(value);

You have to get the endianness right on these things.  Netlink could
theoretically be done over a network, so just saying "device and
system endianness match" is not a valid argument.

Typing and endianness is so important for interfaces like this, so
please contruct the interfaces such that the compiler and 'sparse' can
help us make sure it is done properly.

Thanks.

Reply via email to