Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp324195rwe; Thu, 25 Aug 2022 00:29:24 -0700 (PDT) X-Google-Smtp-Source: AA6agR7WFE3+VEsKX8YxZ/GPpQuVh2TRgaObY5pk1XO+zJrZ6pujhh0gpeltB5wfTVkm9xq0Tjhk X-Received: by 2002:a05:6402:3482:b0:446:dd44:7125 with SMTP id v2-20020a056402348200b00446dd447125mr2115865edc.65.1661412564612; Thu, 25 Aug 2022 00:29:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661412564; cv=none; d=google.com; s=arc-20160816; b=ngssAMjZI0sB3qECwArMwWVPjqdO514QVzaTF5dEuK5PMoEcs6m4WFVlFAuc8KtfuZ wvYjDD90zIJUIL0Epi4xI6T7RyMDtHKHFO6K3RnvOcOf+dMkhomuAcU0ApxxmkuxeyiJ nccltRhGSB2nT9vB7PpMwueiK9R7qMAG2xDQa0fRL8z4/S/lwGPsaBMXBAc7OAes1UT+ vTdDEaTPWg03dNH7yyb5gTV7yjcbIe/DZt3qxE5HuzcdqBfERQTDtJ9fTTnpkPVhtrfp iMhDFFjptTle0kvvBxV2Zm4lPFXCf99gZ4SHhP89USsVZhlmP6iFx3/X1esfjCZUTTek RaIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iP30pHrSfvf//uv6vYc2HV2OsHCadoMIEZDRU1K2e5k=; b=RYn2f/FMIW9erBxEDaqvp21bZaKjaZhUiYTqBQ3fDImOiagz1Pz2lCOobvgqqjWN0X B1fgI5pCyIz7WfZGygltUk8akhT8WwYM4OleQmtrfxxx1QEiY5tZkpry5QzqN3xSXyYf lltWY9+UwDT3A9LW88SknUV0P2bUCyBpSQIdps9QfISWYc62N8tIceAKuxMVoapuFNMm ZapadHXOIrM94NHt+1U5vh+m6W29ZmM2o2+7hwAVjs2vcnErnceV+Bdwb4BOfpJkxoNL VVzrIeffBRxUcBIayDC7CrGByb/CbGpWZwyImIAfr4ClqOa6KOR8BI0a3pPmdXjilV7o aH9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=FjKuASlS; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ionos.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n3-20020a17090695c300b0072ab5d0fc33si3087425ejy.863.2022.08.25.00.28.59; Thu, 25 Aug 2022 00:29:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=FjKuASlS; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ionos.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237676AbiHYHYb (ORCPT + 99 others); Thu, 25 Aug 2022 03:24:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237671AbiHYHY2 (ORCPT ); Thu, 25 Aug 2022 03:24:28 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC61CA1A73 for ; Thu, 25 Aug 2022 00:24:26 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id h22so27551787ejk.4 for ; Thu, 25 Aug 2022 00:24:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=iP30pHrSfvf//uv6vYc2HV2OsHCadoMIEZDRU1K2e5k=; b=FjKuASlS49j208n5Kl+QlCP37BPbCoGM6O6BdIcVjegb3xtzbRMAldDlBrl197HM16 Fho9RC/2JtNXq6ufUP5Iurkcey669vkstHxtp9gShG4Ta62xLiRwfsdMr/866Q8TaMim JeOG2VlimSO56CRUORP2VA/niecVlozajZudJTeY+e6+xZFUEQWulC3tAlK/OASog++P NjJ3hGUALqEODwHpDd+LRMDdBThWApmP6EdxybcUKJKh/FNzrqZw2AnGhAIKCcI8jfhj GktnUz0sKuHyPXM3MW3uIoFB2RINqvOvXHROGspI+r2vlvIgCg4qjmCbYOiWNIkwHOQl cijA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=iP30pHrSfvf//uv6vYc2HV2OsHCadoMIEZDRU1K2e5k=; b=21L+PzF+gkw1GDfMXcgCf374ER0grTtpYpT0lVz2Vp9IYPQ2p3VcveF0Xv+IQLAfOk zrqaG7rdtj08a+H9YbUnXRjaC5pP5MxsOmRanBFZ1oBdg5zU6uXI/uxgtVtNBmyR4/QM 2+1bx8lwTadzaUVb4/oxHBvqTAT94Wd4UeaP7rvWVzJ5bm8DUsWdzUUiCZrmv48+7MJA usSLynWcJCbBg3QhnQ5i+/W1EqXncEEaqARzOG4D7CDi57rfgXymlJwB5RFnJtEw/ja+ /6Pin79CjJygFB319viyIlLXx2qrhvoXtF0Az8tNCu5CQDs7riA76KkPRCsJZqNjry+W stOA== X-Gm-Message-State: ACgBeo2qjxfhHp5FwKuSL43G2ZmjaTBTIqLc6zS5yC5YIih5tVxv0VuU 4YUoDwq5XhQ2lJmgh9HqeL43d27B+Dp1kA== X-Received: by 2002:a17:906:846f:b0:73d:710b:357e with SMTP id hx15-20020a170906846f00b0073d710b357emr1603084ejc.103.1661412265367; Thu, 25 Aug 2022 00:24:25 -0700 (PDT) Received: from lb02065.fritz.box ([2001:9e8:142d:a900:eab:b5b1:a064:1d0d]) by smtp.gmail.com with ESMTPSA id ky12-20020a170907778c00b0073ce4abf093sm2032281ejc.214.2022.08.25.00.24.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Aug 2022 00:24:24 -0700 (PDT) From: Jack Wang To: herbert@gondor.apana.org.au, linux-crypto@vger.kernel.org Cc: Corentin Labbe , "David S. Miller" , linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/6] crypto: amlogic: Fix dma_map_sg error check Date: Thu, 25 Aug 2022 09:24:19 +0200 Message-Id: <20220825072421.29020-5-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220825072421.29020-1-jinpu.wang@ionos.com> References: <20220825072421.29020-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org dma_map_sg return 0 on error. Cc: Corentin Labbe Cc: Herbert Xu Cc: "David S. Miller" Cc: linux-crypto@vger.kernel.org Cc: linux-amlogic@lists.infradead.org Cc: linux-kernel@vger.kernel.org Fixes: 48fe583fe541 ("crypto: amlogic - Add crypto accelerator for amlogic GXL") Signed-off-by: Jack Wang --- drivers/crypto/amlogic/amlogic-gxl-cipher.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/amlogic/amlogic-gxl-cipher.c b/drivers/crypto/amlogic/amlogic-gxl-cipher.c index e79514fce731..af017a087ebf 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-cipher.c +++ b/drivers/crypto/amlogic/amlogic-gxl-cipher.c @@ -177,7 +177,7 @@ static int meson_cipher(struct skcipher_request *areq) if (areq->src == areq->dst) { nr_sgs = dma_map_sg(mc->dev, areq->src, sg_nents(areq->src), DMA_BIDIRECTIONAL); - if (nr_sgs < 0) { + if (!nr_sgs) { dev_err(mc->dev, "Invalid SG count %d\n", nr_sgs); err = -EINVAL; goto theend; @@ -186,14 +186,14 @@ static int meson_cipher(struct skcipher_request *areq) } else { nr_sgs = dma_map_sg(mc->dev, areq->src, sg_nents(areq->src), DMA_TO_DEVICE); - if (nr_sgs < 0 || nr_sgs > MAXDESC - 3) { + if (!nr_sgs || nr_sgs > MAXDESC - 3) { dev_err(mc->dev, "Invalid SG count %d\n", nr_sgs); err = -EINVAL; goto theend; } nr_sgd = dma_map_sg(mc->dev, areq->dst, sg_nents(areq->dst), DMA_FROM_DEVICE); - if (nr_sgd < 0 || nr_sgd > MAXDESC - 3) { + if (!nr_sgd || nr_sgd > MAXDESC - 3) { dev_err(mc->dev, "Invalid SG count %d\n", nr_sgd); err = -EINVAL; goto theend; -- 2.34.1