From patchwork Mon Apr 16 16:05:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 10343381 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.web.codeaurora.org (Postfix) with ESMTP id AE99260365 for ; Mon, 16 Apr 2018 16:07:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F90428700 for ; Mon, 16 Apr 2018 16:07:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 940C8285FF; Mon, 16 Apr 2018 16:07:33 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, 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 1B529285FF for ; Mon, 16 Apr 2018 16:07:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753028AbeDPQHb (ORCPT ); Mon, 16 Apr 2018 12:07:31 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:42061 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753025AbeDPQHa (ORCPT ); Mon, 16 Apr 2018 12:07:30 -0400 Received: by mail-qt0-f196.google.com with SMTP id j3so15855360qtn.9 for ; Mon, 16 Apr 2018 09:07:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=cb0WPB61mjiuM5RyjnhW+TXlszHfcsfLfil0msONJmY=; b=JmaUaUggpEb6Its+ekUWrdYCmNBmoJPIx0Ko9HSZZSbqKyxZJTiU36G22MAhR9+1xI Uwd3OnVfxP1ccZBElLuQ4rieKDrOZW3sftLeqcIpPheSHu766MdFAGTJWpuOW0GgeORB hPT+diYrBszXzKBWc9eVv6vcQprIjbwRw51yh5vsP92lrXgZZd8mgbLwLV0sgJgwzqQ3 ilqCA+1MTPECyJ3r3SocZ4bVoXfZDCd8ZnoYPsjxU5YX5r3g5j7fnxQmzTo3o0mGugso j49/VxQ2fcgpV031uUnDj+vRkzupPrH78iCnZluzgpAJKyspjpdsjXnmfPdo8GXdwFX8 XElQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=cb0WPB61mjiuM5RyjnhW+TXlszHfcsfLfil0msONJmY=; b=kMOFDK7KZUsxScvaCH6V6Xt8JWZoYW0UMtBBFycoIeFxPzIkZM2MAiSSTWMUVxVuXn JeI9ZjQOLXeHYA6UOJVZjwCkHb8AZQjBDplB9xyOPrYwm5kgvnRtqZl46RMvDSpi8nJP pCGQcvuLhnzip+vTgV00M3PLdk1yweM1n8BbaiQ0c4W/DBMwovA9GhqKWo+GE+cTGMMw 1UpOng54oQ7tJ8YmA+8Q5qLC0Dfm7d4qVLY/nncIc20b3SjOWugxGMwojNGytlIBXtAT RIRR9xp/0y4kJOz4/YTJiR9+q04QaaKmRoiatMnpPpXL/+EIB7Mtid07mKeQ7mEbLK5G E/gA== X-Gm-Message-State: ALQs6tAQXU/8JEsgCJpNGzy+hTpnuvdj+kxvIKWkrBR38+gV+zkSZdDW OvPX06glwkYGt1osi90XdQE= X-Google-Smtp-Source: AIpwx4/KxaeM5fwZMY30Xg/HQ5FtsZYihzE8xJNFLYcHFyzKsJouy1dE3ev+H6g/l6UGMYh6kL8t8w== X-Received: by 10.237.47.229 with SMTP id m92mr3661945qtd.232.1523894850040; Mon, 16 Apr 2018 09:07:30 -0700 (PDT) Received: from localhost.localdomain ([187.180.183.211]) by smtp.gmail.com with ESMTPSA id s6sm6495378qkc.7.2018.04.16.09.07.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Apr 2018 09:07:29 -0700 (PDT) From: Fabio Estevam To: herbert@gondor.apana.org.au Cc: horia.geanta@nxp.com, aymen.sghaier@nxp.com, linux-crypto@vger.kernel.org, clabbe.montjoie@gmail.com, Fabio Estevam Subject: [PATCH v2] crypto: caam: - Use kmemdup() function Date: Mon, 16 Apr 2018 13:05:01 -0300 Message-Id: <1523894701-28213-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 2.7.4 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 From: Fabio Estevam Use kmemdup() rather than duplicating its implementation. By usign kmemdup() we can also get rid of the 'val' variable. Detected with Coccinelle script. Signed-off-by: Fabio Estevam Reviewed-by: Horia Geantă --- Changes since v1: - Drop the val variable and return kmemdup() directly. drivers/crypto/caam/caampkc.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/crypto/caam/caampkc.c b/drivers/crypto/caam/caampkc.c index 979072b..6f99013 100644 --- a/drivers/crypto/caam/caampkc.c +++ b/drivers/crypto/caam/caampkc.c @@ -783,19 +783,12 @@ static u8 *caam_read_rsa_crt(const u8 *ptr, size_t nbytes, size_t dstlen) */ static inline u8 *caam_read_raw_data(const u8 *buf, size_t *nbytes) { - u8 *val; caam_rsa_drop_leading_zeros(&buf, nbytes); if (!*nbytes) return NULL; - val = kzalloc(*nbytes, GFP_DMA | GFP_KERNEL); - if (!val) - return NULL; - - memcpy(val, buf, *nbytes); - - return val; + return kmemdup(buf, *nbytes, GFP_DMA | GFP_KERNEL); } static int caam_rsa_check_key_length(unsigned int len)