From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752071AbbJJTOe (ORCPT ); Sat, 10 Oct 2015 15:14:34 -0400 Received: from smtprelay0020.hostedemail.com ([216.40.44.20]:46036 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750737AbbJJTOd (ORCPT ); Sat, 10 Oct 2015 15:14:33 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::,RULES_HIT:41:355:379:541:599:966:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1538:1568:1593:1594:1711:1714:1730:1747:1777:1792:2196:2199:2393:2559:2562:2828:3138:3139:3140:3141:3142:3151:3622:3865:3866:3868:3870:3871:3872:3873:4321:4385:5007:6119:6261:7903:10004:10400:10848:11232:11657:11658:11914:12043:12296:12517:12519:12740:13069:13311:13357:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: frog14_44a2d036e5444 X-Filterd-Recvd-Size: 1560 Message-ID: <1444504470.8012.15.camel@perches.com> Subject: Re: [PATCH] misc: mic: use kstrdup() in cosm_sysfs From: Joe Perches To: Geliang Tang Cc: Greg Kroah-Hartman , Sudeep Dutt , Nikhil Rao , Ashutosh Dixit , linux-kernel@vger.kernel.org Date: Sat, 10 Oct 2015 12:14:30 -0700 In-Reply-To: <5099ee411bd5797e8c24a4e2daa6c58f119ab9ce.1444505802.git.geliangtang@163.com> References: <5099ee411bd5797e8c24a4e2daa6c58f119ab9ce.1444505802.git.geliangtang@163.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.11-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2015-10-10 at 04:46 -0700, Geliang Tang wrote: > Use kstrdup instead of kmalloc and strncpy. As count is a function argument, this isn't the same code. You should state why it's correct in the commit log. > diff --git a/drivers/misc/mic/cosm/cosm_sysfs.c b/drivers/misc/mic/cosm/cosm_sysfs.c [] > @@ -211,18 +211,14 @@ cmdline_store(struct device *dev, struct device_attribute *attr, > mutex_lock(&cdev->cosm_mutex); > kfree(cdev->cmdline); > > - cdev->cmdline = kmalloc(count + 1, GFP_KERNEL); > + cdev->cmdline = kstrdup(buf, GFP_KERNEL);