Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6385214pxv; Thu, 29 Jul 2021 13:17:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSzE9YfZHtE6fyW0vl+1ebXSAYgBGKlh1LU9qLpAB7o5T5uBjz4l7N3zuY4qfj1rbicb7k X-Received: by 2002:a05:6602:1647:: with SMTP id y7mr5488540iow.30.1627589828007; Thu, 29 Jul 2021 13:17:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627589828; cv=none; d=google.com; s=arc-20160816; b=eJHROYN41ZACCxW299GnYII4iawNtuAvW/untNT9ZgIDuvznXx9uENu6U0+vOtC/Pq 5TAhyDoYZL5WNROcSdlbkvTQu7/srWRbm341uhENRxwFai3K4CTGaDTT9lEb95/MSsiH df8npno3Jy4Z643H8QBUSkX18ApTdnWa5uebLPiv2B1Jrd4l044JcO+cH8sJEzy55zjP w0SZft1yUIx0GfVZ/k3pS2yHmP1PvqSrVtnki7laVNoaIIMChpxKcdL7NkThG+Nvuk5Y 60J0Kb2LlX8XUA7JY7wIIqwUio+gxT7CVZUhfCEwBNY06NHOpo+dPwx75uu+6Cxgj+c7 dQgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from:dkim-signature; bh=X/PGh6GTfJ6ZdtihVioh5gR+sLDdDHokoaBTKsSS/Sc=; b=JjfOMpqzyeqpZWRRP2X4KIio0vcahOQp9KiwkUO8e22DVKdyrJ3HoL5PYV5oSh4y0s duqXGgCNAU7YiJ/l+JQVXkaxKV61UL4GYNe0VpZ23vKjyp3/kbYkz3OHVqFLqIKFBi/O /hKjmQH/v4d9vKKsGGZocEzyWTLmcf+iFN8xXR7F2MKDzD71bZtjmvkIg/VYczBFNES1 2Bw/rA0bH3kimKjDyUMoNjDwTKFR7mAesFgIY0TB1M7o+KntprW14IaNa96vE1kY/AQB CP1Q+3YHxgtGhozSWizFq03ce+PMmqzFXevdxhB29aaSb4LuXCNXY9KNgdYKO+jeHDZH 31AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=Cl0pwajP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deltatee.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t23si4266192iog.21.2021.07.29.13.16.53; Thu, 29 Jul 2021 13:17:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=Cl0pwajP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deltatee.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233153AbhG2UQI (ORCPT + 99 others); Thu, 29 Jul 2021 16:16:08 -0400 Received: from ale.deltatee.com ([204.191.154.188]:59098 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229788AbhG2UP5 (ORCPT ); Thu, 29 Jul 2021 16:15:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:MIME-Version:References:In-Reply-To: Message-Id:Date:Cc:To:From:content-disposition; bh=X/PGh6GTfJ6ZdtihVioh5gR+sLDdDHokoaBTKsSS/Sc=; b=Cl0pwajPUF0MbvvK+bH3m8G15c iHGMTRHjC70auqPKPrfU/+fnjiDq8xpUMiFyYl3bcXjcpeMj0bAqbgfhD+GY9+ktWOOjLziknbBpV eOrDDhbu2P6PbvlVWSvYgPEnlp2BricnQaa43UTkbJu+XUYXR7je7h3vqOKBtF35iiPZChQvy2Y6T SQk28+qNruG/mX+ypm5KCA5pmv+A8RtK+979e9bCfNDpbieX0+q4/AvvQXFkzgOrHSbjqtMqcmzC3 ChuWTdKg/GFTa5IPAkYTKqDInd6tjgcT2Sy8uBUU77cbYGKw3nkXhBa/lC9mrNgps7kOEZnUPfeL7 SViD+cFQ==; Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m9CRZ-0008VM-Dl; Thu, 29 Jul 2021 14:15:50 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.92) (envelope-from ) id 1m9CRW-0001UQ-LZ; Thu, 29 Jul 2021 14:15:46 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, iommu@lists.linux-foundation.org, linux-parisc@vger.kernel.org, xen-devel@lists.xenproject.org Cc: Christoph Hellwig , Marek Szyprowski , Robin Murphy , Stephen Bates , Martin Oliveira , Logan Gunthorpe Date: Thu, 29 Jul 2021 14:15:39 -0600 Message-Id: <20210729201539.5602-22-logang@deltatee.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210729201539.5602-1-logang@deltatee.com> References: <20210729201539.5602-1-logang@deltatee.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org, linux-ia64@vger.kernel.org, linux-mips@vger.kernel.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, linux-parisc@vger.kernel.org, xen-devel@lists.xenproject.org, hch@lst.de, m.szyprowski@samsung.com, robin.murphy@arm.com, sbates@raithlin.com, martin.oliveira@eideticom.com, logang@deltatee.com X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-6.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, MYRULES_NO_TEXT autolearn=no autolearn_force=no version=3.4.2 Subject: [PATCH v3 21/21] dma-mapping: Disallow .map_sg operations from returning zero on error X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that all the .map_sg operations have been converted to returning proper error codes, drop the code to handle a zero return value, add a warning if a zero is returned. Signed-off-by: Logan Gunthorpe --- kernel/dma/mapping.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c index 9f0bb56eb9aa..cbcbdc877458 100644 --- a/kernel/dma/mapping.c +++ b/kernel/dma/mapping.c @@ -196,8 +196,8 @@ static int __dma_map_sg_attrs(struct device *dev, struct scatterlist *sg, if (ents > 0) debug_dma_map_sg(dev, sg, nents, ents, dir); - else if (WARN_ON_ONCE(ents != -EINVAL && ents != -ENOMEM && - ents != -EIO && ents != 0)) + else if (WARN_ON_ONCE((ents != -EINVAL && ents != -ENOMEM && + ents != -EIO) || ents == 0)) return -EIO; return ents; @@ -262,9 +262,7 @@ int dma_map_sgtable(struct device *dev, struct sg_table *sgt, int nents; nents = __dma_map_sg_attrs(dev, sgt->sgl, sgt->orig_nents, dir, attrs); - if (nents == 0) - return -EIO; - else if (nents < 0) + if (nents < 0) return nents; sgt->nents = nents; -- 2.20.1