From patchwork Mon Jan 21 07:57:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yue Haibing X-Patchwork-Id: 10772775 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE0091390 for ; Mon, 21 Jan 2019 07:51:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E06D9299C5 for ; Mon, 21 Jan 2019 07:51:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4B9B29D18; Mon, 21 Jan 2019 07:51:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B703F299C5 for ; Mon, 21 Jan 2019 07:51:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728489AbfAUHvT (ORCPT ); Mon, 21 Jan 2019 02:51:19 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2281 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726240AbfAUHvT (ORCPT ); Mon, 21 Jan 2019 02:51:19 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 2A6C61E3DAC6B4FCC9DA; Mon, 21 Jan 2019 15:51:17 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.408.0; Mon, 21 Jan 2019 15:51:09 +0800 From: YueHaibing To: Herbert Xu CC: YueHaibing , , Subject: [PATCH -next] crypto: seqiv - Use kmemdup in seqiv_aead_encrypt() Date: Mon, 21 Jan 2019 07:57:00 +0000 Message-ID: <1548057420-140382-1-git-send-email-yuehaibing@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 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 X-Virus-Scanned: ClamAV using ClamSMTP Use kmemdup rather than duplicating its implementation Signed-off-by: YueHaibing --- crypto/seqiv.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/crypto/seqiv.c b/crypto/seqiv.c index 64a412b..ed1b0e9 100644 --- a/crypto/seqiv.c +++ b/crypto/seqiv.c @@ -89,13 +89,12 @@ static int seqiv_aead_encrypt(struct aead_request *req) if (unlikely(!IS_ALIGNED((unsigned long)info, crypto_aead_alignmask(geniv) + 1))) { - info = kmalloc(ivsize, req->base.flags & - CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL: - GFP_ATOMIC); + info = kmemdup(req->iv, ivsize, req->base.flags & + CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL : + GFP_ATOMIC); if (!info) return -ENOMEM; - memcpy(info, req->iv, ivsize); compl = seqiv_aead_encrypt_complete; data = req; }