lkml.org 
[lkml]   [2017]   [Jun]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] xattr: fix kstrdup.cocci warnings
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 <stefanb@linux.vnet.ibm.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
---

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;

\
 
 \ /
  Last update: 2017-06-24 23:04    [W:0.226 / U:0.464 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site