CC: [email protected]
CC: [email protected]
TO: Stephen Smalley <[email protected]>
CC: Paul Moore <[email protected]>
CC: Eric Paris <[email protected]>
CC: Ondrej Mosnacek <[email protected]>
CC: Tom Rix <[email protected]>
CC: Ethan Edwards <[email protected]>
CC: Wei Yongjun <[email protected]>
CC: [email protected]
CC: [email protected]

From: kernel test robot <[email protected]>

security/selinux/ss/conditional.c:689:9-16: WARNING opportunity for kmemdup

 Use kmemdup rather than duplicating its implementation

Generated by: scripts/coccinelle/api/memdup.cocci

Fixes: c7c556f1e81b ("selinux: refactor changing booleans")
CC: Stephen Smalley <[email protected]>
Signed-off-by: kernel test robot <[email protected]>
---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux.git next
head:   37ea433c66070fcef09c6d118492c36299eb72ba
commit: c7c556f1e81bb9e09656ed6650d0c44c84b7c016 [4/6] selinux: refactor 
changing booleans
:::::: branch date: 4 hours ago
:::::: commit date: 2 days ago

Please take the patch only if it's a positive warning. Thanks!

 conditional.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

--- a/security/selinux/ss/conditional.c
+++ b/security/selinux/ss/conditional.c
@@ -686,12 +686,11 @@ static int cond_bools_copy(struct hashta
 {
        struct cond_bool_datum *datum;
 
-       datum = kmalloc(sizeof(struct cond_bool_datum), GFP_KERNEL);
+       datum = kmemdup(orig->datum, sizeof(struct cond_bool_datum),
+                       GFP_KERNEL);
        if (!datum)
                return -ENOMEM;
 
-       memcpy(datum, orig->datum, sizeof(struct cond_bool_datum));
-
        new->key = orig->key; /* No need to copy, never modified */
        new->datum = datum;
        return 0;
_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to