On Sat, May 27, 2017 at 06:57:38PM +0300, Andy Shevchenko wrote: > On Fri, May 26, 2017 at 7:09 PM, Mika Westerberg > <mika.westerb...@linux.intel.com> wrote: > > The device DROM contains name of the vendor and device among other > > things. Extract this information and expose it to the userspace via two > > new attributes. > > > +static const char *parse_name(const u8 *data, u8 len) > > Hmm... (name) > > > +{ > > + char *name; > > + > > + name = kmemdup(data, len, GFP_KERNEL); > > Since it's ASCII by specification it may make sense to use > > sw->..._name = kstrndup(entry->data, sizeof(*header), GFP_KERNEL); > if (!sw->..._name) > return -ENOMEM; > > just in place, instead of this entire function.
I did not even know we have kstrndup(). Cool, I'll change that but the length needs to be header->len - sizeof(*header) instead of sizeof(*header).