From patchwork Fri May 14 19:30:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 52660 X-Patchwork-Delegate: benh@kernel.crashing.org Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id B695FB7F0F for ; Sat, 15 May 2010 05:55:59 +1000 (EST) Received: by ozlabs.org (Postfix) id F3B05B7E21; Sat, 15 May 2010 05:55:16 +1000 (EST) Delivered-To: linuxppc-dev@ozlabs.org X-Greylist: delayed 1493 seconds by postgrey-1.32 at bilbo; Sat, 15 May 2010 05:55:16 EST Received: from mgw1.diku.dk (mgw1.diku.dk [130.225.96.91]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mgw1.diku.dk", Issuer "KU Security Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 90DE7B7E0E for ; Sat, 15 May 2010 05:55:16 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by mgw1.diku.dk (Postfix) with ESMTP id 9D2E852C4E3; Fri, 14 May 2010 21:30:17 +0200 (CEST) Received: from mgw1.diku.dk ([127.0.0.1]) by localhost (mgw1.diku.dk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id u+iE8d9o0wxd; Fri, 14 May 2010 21:30:13 +0200 (CEST) Received: from nhugin.diku.dk (nhugin.diku.dk [130.225.96.140]) by mgw1.diku.dk (Postfix) with ESMTP id 5C30E52C44C; Fri, 14 May 2010 21:30:13 +0200 (CEST) Received: from ask.diku.dk (ask.diku.dk [130.225.96.225]) by nhugin.diku.dk (Postfix) with ESMTP id 4A4CC6DFD25; Fri, 14 May 2010 21:23:03 +0200 (CEST) Received: by ask.diku.dk (Postfix, from userid 3767) id 3CC8C200BE; Fri, 14 May 2010 21:30:13 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by ask.diku.dk (Postfix) with ESMTP id 349D7200BD; Fri, 14 May 2010 21:30:13 +0200 (CEST) Date: Fri, 14 May 2010 21:30:13 +0200 (CEST) From: Julia Lawall To: Benjamin Herrenschmidt , Paul Mackerras , linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH 6/10] arch/powerpc/platforms/pseries: Use kstrdup Message-ID: MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org From: Julia Lawall Use kstrdup when the goal of an allocation is copy a string into the allocated region. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression from,to; expression flag,E1,E2; statement S; @@ - to = kmalloc(strlen(from) + 1,flag); + to = kstrdup(from, flag); ... when != \(from = E1 \| to = E1 \) if (to==NULL || ...) S ... when != \(from = E2 \| to = E2 \) - strcpy(to, from); // Signed-off-by: Julia Lawall --- arch/powerpc/platforms/pseries/reconfig.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff -u -p a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c --- a/arch/powerpc/platforms/pseries/reconfig.c +++ b/arch/powerpc/platforms/pseries/reconfig.c @@ -118,12 +118,10 @@ static int pSeries_reconfig_add_node(con if (!np) goto out_err; - np->full_name = kmalloc(strlen(path) + 1, GFP_KERNEL); + np->full_name = kstrdup(path, GFP_KERNEL); if (!np->full_name) goto out_err; - strcpy(np->full_name, path); - np->properties = proplist; of_node_set_flag(np, OF_DYNAMIC); kref_init(&np->kref);