Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755160AbdFXVCu (ORCPT ); Sat, 24 Jun 2017 17:02:50 -0400 Received: from mga09.intel.com ([134.134.136.24]:14043 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755087AbdFXVCs (ORCPT ); Sat, 24 Jun 2017 17:02:48 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,386,1493708400"; d="scan'208";a="278276572" Date: Sun, 25 Jun 2017 05:02:24 +0800 From: kbuild test robot To: Stefan Berger Cc: kbuild-all@01.org, ebiederm@xmission.com, containers@lists.linux-foundation.org, lkp@01.org, xiaolong.ye@intel.com, linux-kernel@vger.kernel.org, zohar@linux.vnet.ibm.com, serge@hallyn.com, tycho@docker.com, James.Bottomley@HansenPartnership.com, christian.brauner@mailbox.org, stefanb@linux.vnet.ibm.com, vgoyal@redhat.com, amir73il@gmail.com, linux-security-module@vger.kernel.org Subject: [PATCH] xattr: fix kstrdup.cocci warnings Message-ID: <20170624210224.GA140192@lkp-ib03.lkp.intel.com> References: <201706250409.PFosMVWz%fengguang.wu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1498157989-11814-2-git-send-email-stefanb@linux.vnet.ibm.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: fengguang.wu@intel.com X-SA-Exim-Scanned: No (on bee); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 666 Lines: 27 fs/xattr.c:516:10-17: WARNING opportunity for kstrdep (strcpy on line 519) Use kstrdup rather than duplicating its implementation Generated by: scripts/coccinelle/api/kstrdup.cocci CC: Stefan Berger Signed-off-by: Fengguang Wu --- xattr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/fs/xattr.c +++ b/fs/xattr.c @@ -513,10 +513,9 @@ xattr_userns_name(const char *fullname, return buffer; out_copy: - buffer = kmalloc(strlen(suffix) + 1, GFP_KERNEL); + buffer = kstrdup(suffix, GFP_KERNEL); if (!buffer) return ERR_PTR(-ENOMEM); - strcpy(buffer, suffix); return buffer;