diff options
author | Tadeusz Struk <tadeusz.struk@intel.com> | 2015-03-19 15:31:30 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-23 16:41:37 -0400 |
commit | 66db37391dad834a4f739984eec81af27a68b09c (patch) | |
tree | dcd1d019cb5b04bd044ca1d768f45dc9cfadb1d5 /crypto | |
parent | 0345f93138b2224e0d7ce91fcffdb3dd23f364d7 (diff) |
crypto: af_alg - Allow to link sgl
Allow to link af_alg sgls.
Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/af_alg.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/crypto/af_alg.c b/crypto/af_alg.c index 7f8b7edcadca..26089d182cb7 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c | |||
@@ -358,8 +358,8 @@ int af_alg_make_sg(struct af_alg_sgl *sgl, struct iov_iter *iter, int len) | |||
358 | npages = (off + n + PAGE_SIZE - 1) >> PAGE_SHIFT; | 358 | npages = (off + n + PAGE_SIZE - 1) >> PAGE_SHIFT; |
359 | if (WARN_ON(npages == 0)) | 359 | if (WARN_ON(npages == 0)) |
360 | return -EINVAL; | 360 | return -EINVAL; |
361 | 361 | /* Add one extra for linking */ | |
362 | sg_init_table(sgl->sg, npages); | 362 | sg_init_table(sgl->sg, npages + 1); |
363 | 363 | ||
364 | for (i = 0, len = n; i < npages; i++) { | 364 | for (i = 0, len = n; i < npages; i++) { |
365 | int plen = min_t(int, len, PAGE_SIZE - off); | 365 | int plen = min_t(int, len, PAGE_SIZE - off); |
@@ -369,18 +369,26 @@ int af_alg_make_sg(struct af_alg_sgl *sgl, struct iov_iter *iter, int len) | |||
369 | off = 0; | 369 | off = 0; |
370 | len -= plen; | 370 | len -= plen; |
371 | } | 371 | } |
372 | sg_mark_end(sgl->sg + npages - 1); | ||
373 | sgl->npages = npages; | ||
374 | |||
372 | return n; | 375 | return n; |
373 | } | 376 | } |
374 | EXPORT_SYMBOL_GPL(af_alg_make_sg); | 377 | EXPORT_SYMBOL_GPL(af_alg_make_sg); |
375 | 378 | ||
379 | void af_alg_link_sg(struct af_alg_sgl *sgl_prev, struct af_alg_sgl *sgl_new) | ||
380 | { | ||
381 | sg_unmark_end(sgl_prev->sg + sgl_prev->npages - 1); | ||
382 | sg_chain(sgl_prev->sg, sgl_prev->npages + 1, sgl_new->sg); | ||
383 | } | ||
384 | EXPORT_SYMBOL(af_alg_link_sg); | ||
385 | |||
376 | void af_alg_free_sg(struct af_alg_sgl *sgl) | 386 | void af_alg_free_sg(struct af_alg_sgl *sgl) |
377 | { | 387 | { |
378 | int i; | 388 | int i; |
379 | 389 | ||
380 | i = 0; | 390 | for (i = 0; i < sgl->npages; i++) |
381 | do { | ||
382 | put_page(sgl->pages[i]); | 391 | put_page(sgl->pages[i]); |
383 | } while (!sg_is_last(sgl->sg + (i++))); | ||
384 | } | 392 | } |
385 | EXPORT_SYMBOL_GPL(af_alg_free_sg); | 393 | EXPORT_SYMBOL_GPL(af_alg_free_sg); |
386 | 394 | ||