From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759879Ab0ENUJk (ORCPT ); Fri, 14 May 2010 16:09:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64516 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757667Ab0ENUJi (ORCPT ); Fri, 14 May 2010 16:09:38 -0400 Subject: Re: [PATCH 7/10] security/selinux/ss: Use kstrdup From: Eric Paris 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 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Date: Fri, 14 May 2010 16:09:28 -0400 Message-ID: <1273867768.2826.30.camel@localhost> 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 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