From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 663AFC433E1 for ; Thu, 20 Aug 2020 10:30:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4A44620658 for ; Thu, 20 Aug 2020 10:30:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730762AbgHTKaF (ORCPT ); Thu, 20 Aug 2020 06:30:05 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:34649 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731506AbgHTKU4 (ORCPT ); Thu, 20 Aug 2020 06:20:56 -0400 X-IronPort-AV: E=Sophos;i="5.76,332,1592863200"; d="scan'208";a="356907302" Received: from abo-173-121-68.mrs.modulonet.fr (HELO hadrien) ([85.68.121.173]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 12:20:51 +0200 Date: Thu, 20 Aug 2020 12:20:51 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Stephen Smalley cc: kbuild-all@lists.01.org, selinux@vger.kernel.org, Paul Moore , Eric Paris , Ondrej Mosnacek , Tom Rix , Ethan Edwards , Wei Yongjun , selinux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] selinux: fix memdup.cocci warnings Message-ID: User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: kernel test robot 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 --- 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 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;