From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750998AbdE1Ip7 (ORCPT ); Sun, 28 May 2017 04:45:59 -0400 Received: from mga06.intel.com ([134.134.136.31]:50827 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750909AbdE1Ip6 (ORCPT ); Sun, 28 May 2017 04:45:58 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,408,1491289200"; d="scan'208";a="973933313" Date: Sun, 28 May 2017 11:45:50 +0300 From: Mika Westerberg To: Andy Shevchenko Cc: Greg Kroah-Hartman , Andreas Noever , Michael Jamet , Yehezkel Bernat , Lukas Wunner , Amir Levy , Andy Lutomirski , Mario Limonciello , Jared.Dominguez@dell.com, Andy Shevchenko , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2 13/27] thunderbolt: Read vendor and device name from DROM Message-ID: <20170528084550.GH2784@lahna.fi.intel.com> References: <20170526160936.54265-1-mika.westerberg@linux.intel.com> <20170526160936.54265-14-mika.westerberg@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 27, 2017 at 06:57:38PM +0300, Andy Shevchenko wrote: > On Fri, May 26, 2017 at 7:09 PM, Mika Westerberg > 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).