Skip to content

Commit 9d9b724

Browse files
Mirsad Todorovaccmaiolino
authored andcommitted
xfs/libxfs: replace kmalloc() and memcpy() with kmemdup()
The source static analysis tool gave the following advice: ./fs/xfs/libxfs/xfs_dir2.c:382:15-22: WARNING opportunity for kmemdup → 382 args->value = kmalloc(len, 383 GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_RETRY_MAYFAIL); 384 if (!args->value) 385 return -ENOMEM; 386 → 387 memcpy(args->value, name, len); 388 args->valuelen = len; 389 return -EEXIST; Replacing kmalloc() + memcpy() with kmemdump() doesn't change semantics. Original code works without fault, so this is not a bug fix but proposed improvement. Link: https://lwn.net/Articles/198928/ Fixes: 94a69db ("xfs: use __GFP_NOLOCKDEP instead of GFP_NOFS") Fixes: 384f3ce ("[XFS] Return case-insensitive match for dentry cache") Fixes: 2451337 ("xfs: global error sign conversion") Cc: Carlos Maiolino <[email protected]> Cc: Darrick J. Wong <[email protected]> Cc: Chandan Babu R <[email protected]> Cc: Dave Chinner <[email protected]> Cc: [email protected] Cc: [email protected] Reviewed-by: "Darrick J. Wong" <[email protected]> Signed-off-by: Mirsad Todorovac <[email protected]> Signed-off-by: Carlos Maiolino <[email protected]>
1 parent 183d988 commit 9d9b724

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

fs/xfs/libxfs/xfs_dir2.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,12 +379,11 @@ xfs_dir_cilookup_result(
379379
!(args->op_flags & XFS_DA_OP_CILOOKUP))
380380
return -EEXIST;
381381

382-
args->value = kmalloc(len,
382+
args->value = kmemdup(name, len,
383383
GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_RETRY_MAYFAIL);
384384
if (!args->value)
385385
return -ENOMEM;
386386

387-
memcpy(args->value, name, len);
388387
args->valuelen = len;
389388
return -EEXIST;
390389
}

0 commit comments

Comments
 (0)