Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp209407rdb; Thu, 30 Nov 2023 02:43:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IH2DYNfE0oiFePKjvq24jZX/SGwrjoOGrz/DplG/aYyGdtVv3qehzaYhIbZktjtfj9tIhw4 X-Received: by 2002:aca:1701:0:b0:3b2:ee69:800b with SMTP id j1-20020aca1701000000b003b2ee69800bmr21822312oii.55.1701341007789; Thu, 30 Nov 2023 02:43:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701341007; cv=none; d=google.com; s=arc-20160816; b=MkRvbuyKzxtsrn+pWQE1SnkX4esjLNSBXfk7uoqHhYrc6RGDTTK2iPi2oCsCIcXYGe Lo2i8DmQ2wHHsnxKHwowunYHwcpG61FH0MFEnxfKxdbFBWQg5SqDkJ0F98lfnGzVWULH sOEHLEL4Yglt4kNQ/znkUNE/+aHJEOFCrgkyXa1AnfIqGkrvaZ8EQGxck2CQYpFAGZpx 2m/kAMWFTxw/H+RAY2pUww5IMpnacgs/F1U7JhhJlrtXaL6Ad1YuUR8DjPQ4AwFQ8tV8 Cnsd13ds5b/5Hubjn6SORf8fDhetKmxdc6Oc+pP3RckxZWi3yLNSxMZ/wTDJzE2bxtA0 4qog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:to:cc:from:subject:references:in-reply-to :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=sGvzjdDwHfUoGoDS2FiQjFuIv3IrXS40KeIEVA9WA5Q=; fh=zis4f3mTYk6DhI8zB69hnd1G4wKGdcnCzE0R4nslPe8=; b=adu6CEeIl8FmPr4AtPa3KtEtlkci2oFg+YaVxzb2iM/yuiBzQG5n7kDkA8MMTotrbg 635bmavAX0uBb45m4FvfgT8Y50gkGtaehyGkJKSoNRoFM6Rq/vPwvK1uaqS6LUQrBe07 H58FRgUc7wU0c2VhfaEdhNrOH6z1i0OjMfU7n1y8bwgZANzYP5e8K0qbIbFSaqft7nHP uSdQE5FEk/Dd/nyApS48TQVig/3G3ZTwL39gabTh96bANdwIOBw2bIkUSNilCXAYsko0 /7sLWQ68IkOgnoc0LB3nw8kcMNwhcT86Snie3pycUV4yNN6r6XL6aSNbdswYNoQVsUCi kQmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FGZCAyHD; spf=pass (google.com: domain of linux-crypto+bounces-409-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-409-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d14-20020a63fd0e000000b005b9b68add8bsi1104172pgh.785.2023.11.30.02.43.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:43:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-409-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FGZCAyHD; spf=pass (google.com: domain of linux-crypto+bounces-409-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-409-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id C18F7B20B06 for ; Thu, 30 Nov 2023 10:43:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4ABF63C079 for ; Thu, 30 Nov 2023 10:43:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FGZCAyHD" X-Original-To: linux-crypto@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC42E3C071 for ; Thu, 30 Nov 2023 10:36:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17286C4339A; Thu, 30 Nov 2023 10:36:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701340606; bh=RjaFcjIuRnKdKLcTUCaGL4xoFcvpDOQ03stuLQOnP14=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=FGZCAyHDyUdYCijgPEpxSVnYG+480sL/RcWgg6kgXt/Tyy6oVPC8IpjrL3T4w9Rzv Fc6UcvwVFWcLKDpY8I7CihM+7/XKwbMDD+cYA3/Mt66F3Ke/QSbuFVHqHDtmLH465f PvnMHs2Q/VUiHc8ld5EXPEbProdwAiIm3yFayoFkyNX0mw8QX6SUCZNc3m38Fp9jz8 YNjbsZWGbtPgiE1mVaTUNDG8AdvsSVSC09a0nNipqmRMLW1vO3NiPZtL1x9i0m4QWs ZR+kgfNyfzPTaLaogVQ/yCTLncTgyFbnHFuzaxXwwv8CVeg869xIY//0hx8/VrHzou N8F4BWPTKOZXA== Content-Type: text/plain; charset="utf-8" Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20231129152145.7767-1-n.zhandarovich@fintech.ru> References: <20231129152145.7767-1-n.zhandarovich@fintech.ru> Subject: Re: [PATCH] crypto: safexcel - Add error handling for dma_map_sg() calls From: Antoine Tenart Cc: Nikita Zhandarovich , Herbert Xu , David S. Miller , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org To: Nikita Zhandarovich Date: Thu, 30 Nov 2023 11:36:43 +0100 Message-ID: <170134060353.9758.8481937396435146454@kwain> Hello Nikita, Quoting Nikita Zhandarovich (2023-11-29 16:21:45) >=20 > diff --git a/drivers/crypto/inside-secure/safexcel_cipher.c b/drivers/cry= pto/inside-secure/safexcel_cipher.c > index 272c28b5a088..ca660f31c15f 100644 > --- a/drivers/crypto/inside-secure/safexcel_cipher.c > +++ b/drivers/crypto/inside-secure/safexcel_cipher.c > @@ -742,9 +742,9 @@ static int safexcel_send_req(struct crypto_async_requ= est *base, int ring, > max(totlen_src, totlen_dst)); > return -EINVAL; > } > - if (sreq->nr_src > 0) > - dma_map_sg(priv->dev, src, sreq->nr_src, > - DMA_BIDIRECTIONAL); > + if ((sreq->nr_src > 0) && > + (!dma_map_sg(priv->dev, src, sreq->nr_src, DMA_BIDIRE= CTIONAL))) > + return -ENOMEM; You can remove one level of parenthesis. Also I'm not sure -ENOMEM is the right error to return. Looking around it seems people got creative about that, IMHO -EIO would be best, but not 100% sure. Same comments for the other chunks. Thanks, Antoine