summaryrefslogtreecommitdiffstats
path: root/lib/sg_split.c
diff options
context:
space:
mode:
authorZhou Wang <wangzhou1@hisilicon.com>2019-07-23 23:54:23 -0400
committerJens Axboe <axboe@kernel.dk>2019-08-08 09:45:01 -0400
commit79e178f4383a3a645f76bc2dd44c477b361c6a98 (patch)
treec414e76b0d0eb6bd2d251f8f1f18198bcf5d5bca /lib/sg_split.c
parentba6f7da99aaf00042b4ed2d8850ed7534492009e (diff)
lib: scatterlist: Fix to support no mapped sg
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 <wangzhou1@hisilicon.com> Acked-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'lib/sg_split.c')
-rw-r--r--lib/sg_split.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/sg_split.c b/lib/sg_split.c
index 9982c63d1063..60a0babebf2e 100644
--- a/lib/sg_split.c
+++ b/lib/sg_split.c
@@ -176,11 +176,13 @@ int sg_split(struct scatterlist *in, const int in_mapped_nents,
176 * The order of these 3 calls is important and should be kept. 176 * The order of these 3 calls is important and should be kept.
177 */ 177 */
178 sg_split_phys(splitters, nb_splits); 178 sg_split_phys(splitters, nb_splits);
179 ret = sg_calculate_split(in, in_mapped_nents, nb_splits, skip, 179 if (in_mapped_nents) {
180 split_sizes, splitters, true); 180 ret = sg_calculate_split(in, in_mapped_nents, nb_splits, skip,
181 if (ret < 0) 181 split_sizes, splitters, true);
182 goto err; 182 if (ret < 0)
183 sg_split_mapped(splitters, nb_splits); 183 goto err;
184 sg_split_mapped(splitters, nb_splits);
185 }
184 186
185 for (i = 0; i < nb_splits; i++) { 187 for (i = 0; i < nb_splits; i++) {
186 out[i] = splitters[i].out_sg; 188 out[i] = splitters[i].out_sg;