Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp196721ybx; Fri, 1 Nov 2019 01:56:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxh7w/PffSUTosP9Lk7uesMazhlrkG4WnxIdbfB6Mmdj8Bo6KcITQG0EM/u5YWt4oV6+lw/ X-Received: by 2002:a17:906:85da:: with SMTP id i26mr8737265ejy.186.1572598597355; Fri, 01 Nov 2019 01:56:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572598597; cv=none; d=google.com; s=arc-20160816; b=tu0uJ3HVs4oYGOeo9n94uB81MWRoxUUD66C5c0Rw6xQ469rhH0ttUZXPRm8N/EXbXs YCkVVLHiHkalWG2oMFp80b/WfpWCwUlpdPDAplG34Hjl+IQZSNRRNIAnAnindUDL+LFC P+Nr5veG0bN+B0A7auR65p4Jh56bjw1EcqHZ4JE8sYD0+y7OqZ8+E0Eq1R7HZYl5Wlrc UOibo9B3rM/U/jss+nM3kcoJJBW9ggFRdrgKjIp+QkGxv/lQ/rUpgJQXJlJzI0xEB4pq EYvIWdFSJ4L4D0NZCFjGVJY1pdytuP0t7FBOauFYpNEHS2fw7t4IR6buTZJ/nlzhCrwE 8tkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :subject:cc:to:from:date; bh=yoeRQjkZHTKJsDpvaH8up03Gc5+syLGxKlbGfzTqjJg=; b=cJdJknfrJ5XuqBFV2SFJ2yrkj+Z33bUIv9pyo6G5Wz3opa/UNdK3cMmNvCKGXam0GN f1z4C+151wWB2jffjfvxCBRc5F53qUTH+i4YgsKARRsdtltqFQMUrAg5ucuM089+yEJI dtGCqVnRYoxdw3geyG8WlBVSmLiBi3nn6s6zOiAoBw3VtpZbZwbAddkkoXgu3nFvJVv0 0+GnOFizBxatS1OcNwdtVFLyqJiBvunUexI96qsTVG1Jn8sxzn33DoNdkdTtBKyQWCUA JbrdH2anG+Fi94CaQEnWXPlXPQ9Vs0PUrjNDLPCRiaCuL3W2Palgbvib0GK3mFg2KgX5 rbvA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y38si6367958edb.87.2019.11.01.01.56.13; Fri, 01 Nov 2019 01:56:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726689AbfKAIzh (ORCPT + 99 others); Fri, 1 Nov 2019 04:55:37 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:39608 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726663AbfKAIzh (ORCPT ); Fri, 1 Nov 2019 04:55:37 -0400 X-IronPort-AV: E=Sophos;i="5.68,254,1569276000"; d="scan'208";a="409892343" Received: from abo-45-121-68.mrs.modulonet.fr (HELO hadrien) ([85.68.121.45]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Nov 2019 09:55:35 +0100 Date: Fri, 1 Nov 2019 09:55:34 +0100 (CET) From: Julia Lawall X-X-Sender: jll@hadrien To: Corentin Labbe cc: kbuild-all@lists.01.org, linux-crypto@vger.kernel.org, Herbert Xu , Maxime Ripard , Chen-Yu Tsai , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] crypto: fix memdup.cocci warnings Message-ID: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: kbuild test robot Use kmemdup rather than duplicating its implementation Generated by: scripts/coccinelle/api/memdup.cocci Fixes: f08fcced6d00 ("crypto: allwinner - Add sun8i-ss cryptographic offloader") CC: Corentin Labbe Signed-off-by: kbuild test robot Signed-off-by: Julia Lawall --- tree: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master head: 298b4c604008025b134bc6fccbc4018449945d60 commit: f08fcced6d0017c39cb6eccb571290867119d049 [154/163] crypto: allwinner - Add sun8i-ss cryptographic offloader :::::: branch date: 3 hours ago :::::: commit date: 3 hours ago Please take the patch only if it's a positive warning. Thanks! sun8i-ss-cipher.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) --- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c +++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c @@ -398,10 +398,9 @@ int sun8i_ss_aes_setkey(struct crypto_sk kfree(op->key); } op->keylen = keylen; - op->key = kmalloc(keylen, GFP_KERNEL | GFP_DMA); + op->key = kmemdup(key, keylen, GFP_KERNEL | GFP_DMA); if (!op->key) return -ENOMEM; - memcpy(op->key, key, keylen); crypto_sync_skcipher_clear_flags(op->fallback_tfm, CRYPTO_TFM_REQ_MASK); crypto_sync_skcipher_set_flags(op->fallback_tfm, tfm->base.crt_flags & CRYPTO_TFM_REQ_MASK); @@ -426,10 +425,9 @@ int sun8i_ss_des3_setkey(struct crypto_s kfree(op->key); } op->keylen = keylen; - op->key = kmalloc(keylen, GFP_KERNEL | GFP_DMA); + op->key = kmemdup(key, keylen, GFP_KERNEL | GFP_DMA); if (!op->key) return -ENOMEM; - memcpy(op->key, key, keylen); crypto_sync_skcipher_clear_flags(op->fallback_tfm, CRYPTO_TFM_REQ_MASK); crypto_sync_skcipher_set_flags(op->fallback_tfm, tfm->base.crt_flags & CRYPTO_TFM_REQ_MASK);