From patchwork Mon Jul 29 10:40:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 169973 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp1099201ile; Mon, 29 Jul 2019 03:40:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/TalxmgQxAevh3IBfYQe7K7dhqyPFserEOfTBCEFnUAq+tgZ3VNeGWxsDwQBUUeYEMd8r X-Received: by 2002:aa7:989a:: with SMTP id r26mr23661507pfl.232.1564396841739; Mon, 29 Jul 2019 03:40:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564396841; cv=none; d=google.com; s=arc-20160816; b=GrzUbJBVWshEf2vInTVRTttu60Zy58tAEXlA26oOVm2GqDT6mb+KqQl5hBX5L8njo8 bRqRQp65zjzwlyV7ejC9Tw3hkcNFIntkeWyvFeXo7wVX+2jT7A5e8j7vQ2ZvtcYmV7qx wsRG7PJiH7OIJRzTFP4ve66pp/uRROo6Xf2W1evorZDu/z0Sdc99euOorC3ZcwP2VPj1 d9s0sZMD45nmWxtMQZaYeJHIYrOMS92hBriWOX1CiPJ/sX3kDfDisDQCQijKqYSOEBfE pX/spB9j5rcINR157/Zrr4gkVvhcT7Dgah//RUUewcpSjpcEzO1i78j8vofeb48yyNbw aNdg== 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=B2eR0AaC3gNA7qt8KLJHRR2osV1+9gQjmQw3CnIKwdE=; b=L+BUs+bw+n2NoewfqyFWo4aHpMzltjVG0Mc61Cv/KfHycQrMPmTMZ5fqHCE6A2rqV3 zPPyrge5lVXvm3+POr1N2VyR4o9XOdgUHPwL8YfawsAA62KKCocvL844L/wkT+SrgFtR kqkuM3encvopFfTSJZEgL1VX08qPSGIkHnmKrFxF41Qqo+w5y+5SFjTfxBT2JRaMm88F yaLPuj+GYPaZcShX0AKspopxQlsSF73cVTNP/WI8l2SZFrCaFxuSnWA/gG3FK+APu+Dd Zoj2saQE5vZW6mZp/BPOfuyGJiK3UGvG/2kRJYkvdvG/hoNUmzLUDcMwpGjas4Gwiusn Sndg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 l70si24782477pgd.363.2019.07.29.03.40.41; Mon, 29 Jul 2019 03:40:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387467AbfG2Kkk (ORCPT + 29 others); Mon, 29 Jul 2019 06:40:40 -0400 Received: from foss.arm.com ([217.140.110.172]:41748 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387428AbfG2Kki (ORCPT ); Mon, 29 Jul 2019 06:40:38 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 829F815A2; Mon, 29 Jul 2019 03:40:37 -0700 (PDT) Received: from e110176-lin.kfn.arm.com (unknown [10.50.4.178]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5108C3F694; Mon, 29 Jul 2019 03:40:36 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" Cc: Ofir Drang , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] crypto: ccree: use std api sg_zero_buffer Date: Mon, 29 Jul 2019 13:40:19 +0300 Message-Id: <20190729104020.3681-3-gilad@benyossef.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190729104020.3681-1-gilad@benyossef.com> References: <20190729104020.3681-1-gilad@benyossef.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace internal cc_zero_sgl() with kernel API of the same function sg_zero_buffer(). Signed-off-by: Gilad Ben-Yossef --- drivers/crypto/ccree/cc_aead.c | 3 ++- drivers/crypto/ccree/cc_buffer_mgr.c | 21 --------------------- drivers/crypto/ccree/cc_buffer_mgr.h | 2 -- 3 files changed, 2 insertions(+), 24 deletions(-) -- 2.21.0 diff --git a/drivers/crypto/ccree/cc_aead.c b/drivers/crypto/ccree/cc_aead.c index 8a6c825d40e8..f807875b541f 100644 --- a/drivers/crypto/ccree/cc_aead.c +++ b/drivers/crypto/ccree/cc_aead.c @@ -268,7 +268,8 @@ static void cc_aead_complete(struct device *dev, void *cc_req, int err) /* In case of payload authentication failure, MUST NOT * revealed the decrypted message --> zero its memory. */ - cc_zero_sgl(areq->dst, areq->cryptlen); + sg_zero_buffer(areq->dst, sg_nents(areq->dst), + areq->cryptlen, 0); err = -EBADMSG; } /*ENCRYPT*/ diff --git a/drivers/crypto/ccree/cc_buffer_mgr.c b/drivers/crypto/ccree/cc_buffer_mgr.c index c81ad33f9115..a72586eccd81 100644 --- a/drivers/crypto/ccree/cc_buffer_mgr.c +++ b/drivers/crypto/ccree/cc_buffer_mgr.c @@ -99,27 +99,6 @@ static unsigned int cc_get_sgl_nents(struct device *dev, return nents; } -/** - * cc_zero_sgl() - Zero scatter scatter list data. - * - * @sgl: - */ -void cc_zero_sgl(struct scatterlist *sgl, u32 data_len) -{ - struct scatterlist *current_sg = sgl; - int sg_index = 0; - - while (sg_index <= data_len) { - if (!current_sg) { - /* reached the end of the sgl --> just return back */ - return; - } - memset(sg_virt(current_sg), 0, current_sg->length); - sg_index += current_sg->length; - current_sg = sg_next(current_sg); - } -} - /** * cc_copy_sg_portion() - Copy scatter list data, * from to_skip to end, to dest and vice versa diff --git a/drivers/crypto/ccree/cc_buffer_mgr.h b/drivers/crypto/ccree/cc_buffer_mgr.h index a726016bdbc1..af434872c6ff 100644 --- a/drivers/crypto/ccree/cc_buffer_mgr.h +++ b/drivers/crypto/ccree/cc_buffer_mgr.h @@ -66,6 +66,4 @@ void cc_unmap_hash_request(struct device *dev, void *ctx, void cc_copy_sg_portion(struct device *dev, u8 *dest, struct scatterlist *sg, u32 to_skip, u32 end, enum cc_sg_cpy_direct direct); -void cc_zero_sgl(struct scatterlist *sgl, u32 data_len); - #endif /*__BUFFER_MGR_H__*/