From 879229311bc8a887f00d827525ea59f23861c1ad Mon Sep 17 00:00:00 2001 From: kernel test robot Date: Thu, 20 Aug 2020 12:20:51 +0200 Subject: [PATCH] selinux: fix memdup.cocci warnings Use kmemdup rather than duplicating its implementation Generated by: scripts/coccinelle/api/memdup.cocci Fixes: c7c556f1e81b ("selinux: refactor changing booleans") CC: Stephen Smalley Signed-off-by: kernel test robot Signed-off-by: Julia Lawall Acked-by: Stephen Smalley Signed-off-by: Paul Moore --- security/selinux/ss/conditional.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c index 05c7a10e0aab..0b32f3ab025e 100644 --- a/security/selinux/ss/conditional.c +++ b/security/selinux/ss/conditional.c @@ -686,12 +686,11 @@ static int cond_bools_copy(struct hashtab_node *new, struct hashtab_node *orig, { 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;