Skip to content

Commit

Permalink
lib: scatterlist: Fix to support no mapped sg
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Robert Jarzmik <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Zhou Wang authored and axboe committed Aug 8, 2019
1 parent ba6f7da commit 79e178f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/sg_split.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,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;
Expand Down

0 comments on commit 79e178f

Please sign in to comment.