Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp197282ybc; Mon, 11 Nov 2019 23:25:28 -0800 (PST) X-Google-Smtp-Source: APXvYqzn+Tkk41kessiSgxlzHPlXNCnrSJrueI7KXkORyle6Gu2X2XlKQ/PDyndAheff7tZS1lY5 X-Received: by 2002:a17:906:3393:: with SMTP id v19mr1543874eja.117.1573543528025; Mon, 11 Nov 2019 23:25:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573543528; cv=none; d=google.com; s=arc-20160816; b=Guc0dc3a8tO+xzVXVuvFR6PaHctuGYF0+nf/1KmB7Zrp3Ue4BxSZw9bbCUmR0yqOwM SoAouDfcLlWUKh43M+v++kXDeqGsvyH2xBSnimRstU9SrtPox8onSBMdv727yT9rNaKp M/r/BA0eEAEX6FgUUj6aSwJ8ygnCPHfFvbleZMJrfrYGuA4/sc4OJ+zP6p6C0tuytwzm 77+g7nWjBSJxua4b68Iw/Q1t8eaQs3Ou6OZ0FU5ZpDK1jL3fgLnwIHzI/sD0L6M4G1tI FaZlFvhmKY5iXckdygPb1eMGU1qFqBEvaJjPbUL9cuTZQioNnigbufw5ao5zEaFdx71i G7oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=YNDGP2+bb46jm8p2B8FUzqZD1HRqQVnjUiiZomrnWBU=; b=lDdS0ghDNkoAmpfq39A9/DVorSSnS0XrpeUaIbBu9j39MWvqktFKaxFZLPPuqoPVqa 1OqkrvdyDqe8gRlfz6k+B+U7LDG1zAGwwvc09I/A0JiIMvR2DkY3KPDvSpAoJBJL61ua awNDvAJQ6YBgL1RQOHbd8Z84sF5aLFm+yN5/cC9xOFMSL6Ft97oV5Mjka2MbxiqFIfSN hhJBkz+WDg8oYmW9mXHRvhnPb5H9fJuorMJ//6BQp36jGxwuakFtndxz03BhjpgrE8AI z1PRYvyYFUtygO6DtOJ67bW0r/bQr3pTD+uJN352jZRbPLXnk876ObEEFoBTZLczGcp2 U2yg== 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 t18si11202742eji.130.2019.11.11.23.24.58; Mon, 11 Nov 2019 23:25:28 -0800 (PST) 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 S1725847AbfKLHYv (ORCPT + 99 others); Tue, 12 Nov 2019 02:24:51 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:6638 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725283AbfKLHYv (ORCPT ); Tue, 12 Nov 2019 02:24:51 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 74FF4DEB7E58E6416410; Tue, 12 Nov 2019 15:24:29 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.439.0; Tue, 12 Nov 2019 15:24:18 +0800 From: YueHaibing To: Corentin Labbe , Herbert Xu , Maxime Ripard , "Chen-Yu Tsai" CC: YueHaibing , , , , Subject: [PATCH v2 -next] crypto: sun8i-ce - Fix memdup.cocci warnings Date: Tue, 12 Nov 2019 07:23:14 +0000 Message-ID: <20191112072314.145064-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191109024403.47106-1-yuehaibing@huawei.com> References: <20191109024403.47106-1-yuehaibing@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Use kmemdup rather than duplicating its implementation Signed-off-by: YueHaibing --- v2: fix patch title 'sun8i-ss' -> 'sun8i-ce' --- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c index f0e7c1e12da6..b6e7c346c3ae 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c @@ -396,10 +396,9 @@ int sun8i_ce_aes_setkey(struct crypto_skcipher *tfm, const u8 *key, 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); @@ -422,10 +421,9 @@ int sun8i_ce_des3_setkey(struct crypto_skcipher *tfm, const u8 *key, 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);