lkml.org 
[lkml]   [2017]   [May]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 13/27] thunderbolt: Read vendor and device name from DROM
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.westerberg@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).

\
 
 \ /
  Last update: 2017-05-28 10:46    [W:0.075 / U:7.588 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site