From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Paris Date: Fri, 14 May 2010 20:09:28 +0000 Subject: Re: [PATCH 7/10] security/selinux/ss: Use kstrdup Message-Id: <1273867768.2826.30.camel@localhost> List-Id: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Julia Lawall Cc: Stephen Smalley , James Morris , Eric Paris , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org On Fri, 2010-05-14 at 21:30 +0200, Julia Lawall wrote: > 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 Acked-by: Eric Paris