From patchwork Thu Apr 18 09:50:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhou Wang X-Patchwork-Id: 162451 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp535744jan; Thu, 18 Apr 2019 03:00:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqR6nI3Oaz+aHzJ5ryOaqdHkYGhBtVNT+GEUZ2LXkGU2e3BCaMYdaEg9EUdyjl6QXPUXPl X-Received: by 2002:a63:4548:: with SMTP id u8mr4683860pgk.435.1555581631791; Thu, 18 Apr 2019 03:00:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555581631; cv=none; d=google.com; s=arc-20160816; b=bqoR3C95EkbMlo/7bVCqblsNLELcKeFO0ef4xb76urACZsh35H8Q2Ti6bXeTQbaYn1 WZrjxHlnUaWpAhxv6MT9ibU/uDVSasCQq6gPs1Q9y+msccV0xuQyBfKw0uPRsXfigvMP BCHFJ+A6SlPcSgXjASyylcm2A3hmAXXh1OHepWDIRhncmfKyw4ThB4JG071edGnYe5PF 0MQhV9OtXaTtElGiK6mNoKBiV3qOeexIUi787f5y44ebl25shF+Ib1bPMTOACRSooVg4 ES3yxHuaT/CZHbMwP4Hl+1Wst2GYKfMCYPSwdqQsKG+KOCqDBNMr4bh3FuSnKfebCiyT X4LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=Pu2Zhgf6gkG8qDoNXWyoJs0tptuybsZ0yP0av7Zrj4A=; b=AScFCm1fFnn0sVtUT3RNg7qzyNF+1aP9ARJvgOeT7viNDfGBHSprmqfXO9dW4hIiyv sDkO+eETeolnFnaOxdJsWhsoJXNC2ORIxN7VYhH4g7ODBfgJirL5lqfxblDuDCrhaF/M oauC0dzTUFmPMUq2KbT62SlDUBIZ23n/xUWcI+Lx+ULxG5EF7Zrh+ti7F9wL/Dm4uqf+ jG8imkRlPJ6T7kiR4Of1l6HbilIL5dsJ1qP1v+jBNut8BXXpHnthBNWDYIk/viHzrtIj o7zN47hJ3TFoTeBs9LSrAZskuaffSO1f/nLvE7QWEPsfHZLQ5d9AoS1uUqsmpWrlYlh+ IsBA== 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 l77si1923059pfb.34.2019.04.18.03.00.31; Thu, 18 Apr 2019 03:00:31 -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 S2388524AbfDRKAa (ORCPT + 30 others); Thu, 18 Apr 2019 06:00:30 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:35670 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1733049AbfDRKAa (ORCPT ); Thu, 18 Apr 2019 06:00:30 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 0AF69772A36535CE5C0A; Thu, 18 Apr 2019 18:00:28 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.408.0; Thu, 18 Apr 2019 18:00:17 +0800 From: Zhou Wang To: , CC: , , Zhou Wang Subject: [PATCH] lib: scatterlist: Fix to support no mapped sg Date: Thu, 18 Apr 2019 17:50:06 +0800 Message-ID: <1555581006-153458-1-git-send-email-wangzhou1@hisilicon.com> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In function sg_split, the second sg_calculate_split will return -EINVAL when in_mapped_nents is 0. Indeed there is no need to do second sg_calculate_split and sg_split_mapped when in_mapped_nents is 0, as in_mapped_nents indicates no mapped entry in original sgl. Signed-off-by: Zhou Wang --- lib/sg_split.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) -- 2.8.1 Acked-by: Robert Jarzmik diff --git a/lib/sg_split.c b/lib/sg_split.c index b063410..d4181c8 100644 --- a/lib/sg_split.c +++ b/lib/sg_split.c @@ -178,11 +178,13 @@ int sg_split(struct scatterlist *in, const int in_mapped_nents, * The order of these 3 calls is important and should be kept. */ sg_split_phys(splitters, nb_splits); - ret = sg_calculate_split(in, in_mapped_nents, nb_splits, skip, - split_sizes, splitters, true); - if (ret < 0) - goto err; - sg_split_mapped(splitters, nb_splits); + if (in_mapped_nents) { + ret = sg_calculate_split(in, in_mapped_nents, nb_splits, skip, + split_sizes, splitters, true); + if (ret < 0) + goto err; + sg_split_mapped(splitters, nb_splits); + } for (i = 0; i < nb_splits; i++) { out[i] = splitters[i].out_sg;