Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3263810ybi; Mon, 29 Jul 2019 03:42:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXcHzJsMQeH3Xmd85vA5x4qoq3djbc9EW1sdHw45Zvt/xgaYIseV3spW6ldjt94qKv3p3v X-Received: by 2002:a62:1652:: with SMTP id 79mr35971785pfw.20.1564396942754; Mon, 29 Jul 2019 03:42:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564396942; cv=none; d=google.com; s=arc-20160816; b=DGFkCaEI+dHVnT9+wWkevXD8S9misVPRqSWAFJUkRyl/OxJr9dphrq5SATOC1HqiVR H8MFnvta6NNGgvFLow0kHbHmEb12gn419E0/UjLjIEEWTWje1gmBcYbxQVidw4nNDyxG Wd0FJGIEl65yHr3WcywQsFnqWc5pR73tllul+3scbebrBWEH+lWJbVRwAQZjGdxPjSGD De5EA8j/SuB8uABQyjV19wfg9it5SPe7CKTpFHvm1TxXeoU0TEjfsbGilSGeldAcjIDB L25nPZ1ycUMHoKGATO9T06UdxQTL4KhpBpShF5K/H4Sl0UmbeJYYY6P+gLR12dLCXr/K q4IQ== 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 m71si24020261pjb.26.2019.07.29.03.42.06; Mon, 29 Jul 2019 03:42:22 -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 S2387463AbfG2Kkj (ORCPT + 99 others); Mon, 29 Jul 2019 06:40:39 -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 Content-Transfer-Encoding: 8bit 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(-) 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__*/ -- 2.21.0