From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752332AbbJJTWP (ORCPT ); Sat, 10 Oct 2015 15:22:15 -0400 Received: from smtprelay0129.hostedemail.com ([216.40.44.129]:47331 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751356AbbJJTWO (ORCPT ); Sat, 10 Oct 2015 15:22:14 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::,RULES_HIT:41:355:379:541:599:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1539:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2693:2828:2898:3138:3139:3140:3141:3142:3151:3352:3622:3865:3866:3867:3870:3873:3874:4321:5007:6119:6261:7903:10004:10400:10848:11026:11232:11658:11914:12043:12296:12517:12519:12740:13019: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: crush44_87995b5e62d0f X-Filterd-Recvd-Size: 1660 Message-ID: <1444504930.8012.19.camel@perches.com> Subject: Re: [PATCH] mISDN: use kstrdup() in dsp_pipeline_build From: Joe Perches To: Geliang Tang Cc: Karsten Keil , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Sat, 10 Oct 2015 12:22:10 -0700 In-Reply-To: <1efbeaf13aca3797e7d7f899ca00b27e37bbde9d.1444498002.git.geliangtang@163.com> References: <1efbeaf13aca3797e7d7f899ca00b27e37bbde9d.1444498002.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 02:32 -0700, Geliang Tang wrote: > Use kstrdup instead of strlen-kmalloc-strcpy. Not the same code. Instead of returning early, a 0 length string will now set pipeline->inuse to 0. Maybe that's OK, but you should state why in the commit log. > diff --git a/drivers/isdn/mISDN/dsp_pipeline.c b/drivers/isdn/mISDN/dsp_pipeline.c [] > @@ -250,14 +250,9 @@ int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg) > if (!cfg) > return 0; > > - len = strlen(cfg); > - if (!len) > - return 0; > - > - dup = kmalloc(len + 1, GFP_ATOMIC); > + dup = kstrdup(cfg, GFP_ATOMIC); > if (!dup) > return 0; > - strcpy(dup, cfg); > while ((tok = strsep(&dup, "|"))) { > if (!strlen(tok)) > continue;