From patchwork Fri Aug 7 07:59:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 6966421 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8B06C9F358 for ; Fri, 7 Aug 2015 08:15:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C4B1620631 for ; Fri, 7 Aug 2015 08:15:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C98E32062D for ; Fri, 7 Aug 2015 08:15:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755478AbbHGIAc (ORCPT ); Fri, 7 Aug 2015 04:00:32 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:23212 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755394AbbHGIAb (ORCPT ); Fri, 7 Aug 2015 04:00:31 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NSP00D5FCWU0Y40@mailout2.w1.samsung.com>; Fri, 07 Aug 2015 09:00:30 +0100 (BST) X-AuditID: cbfec7f4-f79c56d0000012ee-59-55c4659eacf4 Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 3A.84.04846.E9564C55; Fri, 7 Aug 2015 09:00:30 +0100 (BST) Received: from AMDC1061.digital.local ([106.116.147.88]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NSP0013BCW67E10@eusync2.samsung.com>; Fri, 07 Aug 2015 09:00:30 +0100 (BST) From: Andrzej Hajda To: Herbert Xu , "David S. Miller" Cc: Andrzej Hajda , Bartlomiej Zolnierkiewicz , Marek Szyprowski , linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org Subject: [PATCH 09/31] crypto: use kmemdup rather than duplicating its implementation Date: Fri, 07 Aug 2015 09:59:15 +0200 Message-id: <1438934377-4922-10-git-send-email-a.hajda@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1438934377-4922-1-git-send-email-a.hajda@samsung.com> References: <1438934377-4922-1-git-send-email-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupmluLIzCtJLcpLzFFi42I5/e/4Fd15qUdCDT4c57G4te4cq8XGGetZ Leacb2Gx6H4lY3H/3k8mi8u75rBZrD1yl92B3WPLyptMHtsOqHr0bVnF6PF5k1wASxSXTUpq TmZZapG+XQJXxqVFVQUHeCv2Nr5lb2B8ztXFyMkhIWAisWfqEjYIW0ziwr31QDYXh5DAUkaJ CS+Os0I4TUwSb579YgSpYhPQlPi7+SZYh4hAuMT9M3eZQWxmgTOMEufeJXcxcnAIA8Vf9QaB hFkEVCWav0xmB7F5BZwl9j3awQyxTE7i5LHJrCA2J1B8ZfdMMFtIwEniTd8F5gmMvAsYGVYx iqaWJhcUJ6XnGuoVJ+YWl+al6yXn525ihATRlx2Mi49ZHWIU4GBU4uFN+Hc4VIg1say4MvcQ owQHs5II70N9oBBvSmJlVWpRfnxRaU5q8SFGaQ4WJXHeubvehwgJpCeWpGanphakFsFkmTg4 pRoYvZiv6SyoWut9f+fqiSv3TV1y5vPfhxctW2uMvLm/35CfGOKr3G117plsHccaX3XBU9N5 DL4l9Fw5zlLwY8dxiWvyq5gvf8vJVvSOfLSx7teaqgcCn2UCNv38y/zuxgwvSdkNIhHpHraO VnUfT9rMe1/6LNrYUMq6TG3P8dXrq/I3cB1etNtltRJLcUaioRZzUXEiANmHRmIeAgAA Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The patch was generated using fixed coccinelle semantic patch scripts/coccinelle/api/memdup.cocci [1]. [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320 Signed-off-by: Andrzej Hajda --- crypto/echainiv.c | 7 ++----- crypto/seqiv.c | 6 ++---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/crypto/echainiv.c b/crypto/echainiv.c index d3896c7..d8968c0 100644 --- a/crypto/echainiv.c +++ b/crypto/echainiv.c @@ -134,13 +134,10 @@ static int echainiv_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); } aead_request_set_callback(subreq, req->base.flags, compl, data); diff --git a/crypto/seqiv.c b/crypto/seqiv.c index 45d0563..eb83236 100644 --- a/crypto/seqiv.c +++ b/crypto/seqiv.c @@ -362,13 +362,11 @@ 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; }