aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--block/ll_rw_blk.c2
-rw-r--r--drivers/scsi/scsi_lib.c2
-rw-r--r--include/linux/scatterlist.h22
-rw-r--r--net/core/skbuff.c2
-rw-r--r--net/ipv4/tcp_ipv4.c2
-rw-r--r--net/ipv6/tcp_ipv6.c2
-rw-r--r--net/rxrpc/rxkad.c2
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_crypto.c6
8 files changed, 21 insertions, 19 deletions
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index 56f2646612e6..54fd38589674 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -1369,7 +1369,7 @@ new_segment:
1369 } /* segments in rq */ 1369 } /* segments in rq */
1370 1370
1371 if (sg) 1371 if (sg)
1372 __sg_mark_end(sg); 1372 sg_mark_end(sg);
1373 1373
1374 return nsegs; 1374 return nsegs;
1375} 1375}
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 61fdaf02f251..88de771d3569 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -785,7 +785,7 @@ struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_mask)
785 * end-of-list 785 * end-of-list
786 */ 786 */
787 if (!left) 787 if (!left)
788 sg_mark_end(sgl, this); 788 sg_mark_end(&sgl[this - 1]);
789 789
790 /* 790 /*
791 * don't allow subsequent mempool allocs to sleep, it would 791 * don't allow subsequent mempool allocs to sleep, it would
diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index d5e1876daf3f..259735044148 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -188,21 +188,23 @@ static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents,
188 188
189/** 189/**
190 * sg_mark_end - Mark the end of the scatterlist 190 * sg_mark_end - Mark the end of the scatterlist
191 * @sgl: Scatterlist 191 * @sg: SG entryScatterlist
192 * @nents: Number of entries in sgl
193 * 192 *
194 * Description: 193 * Description:
195 * Marks the last entry as the termination point for sg_next() 194 * Marks the passed in sg entry as the termination point for the sg
195 * table. A call to sg_next() on this entry will return NULL.
196 * 196 *
197 **/ 197 **/
198static inline void sg_mark_end(struct scatterlist *sgl, unsigned int nents) 198static inline void sg_mark_end(struct scatterlist *sg)
199{
200 sgl[nents - 1].page_link = 0x02;
201}
202
203static inline void __sg_mark_end(struct scatterlist *sg)
204{ 199{
200#ifdef CONFIG_DEBUG_SG
201 BUG_ON(sg->sg_magic != SG_MAGIC);
202#endif
203 /*
204 * Set termination bit, clear potential chain bit
205 */
205 sg->page_link |= 0x02; 206 sg->page_link |= 0x02;
207 sg->page_link &= ~0x01;
206} 208}
207 209
208/** 210/**
@@ -218,7 +220,6 @@ static inline void __sg_mark_end(struct scatterlist *sg)
218static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents) 220static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents)
219{ 221{
220 memset(sgl, 0, sizeof(*sgl) * nents); 222 memset(sgl, 0, sizeof(*sgl) * nents);
221 sg_mark_end(sgl, nents);
222#ifdef CONFIG_DEBUG_SG 223#ifdef CONFIG_DEBUG_SG
223 { 224 {
224 unsigned int i; 225 unsigned int i;
@@ -226,6 +227,7 @@ static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents)
226 sgl[i].sg_magic = SG_MAGIC; 227 sgl[i].sg_magic = SG_MAGIC;
227 } 228 }
228#endif 229#endif
230 sg_mark_end(&sgl[nents - 1]);
229} 231}
230 232
231/** 233/**
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 64b50ff7a413..32d5826b7177 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -2095,7 +2095,7 @@ int skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int le
2095{ 2095{
2096 int nsg = __skb_to_sgvec(skb, sg, offset, len); 2096 int nsg = __skb_to_sgvec(skb, sg, offset, len);
2097 2097
2098 __sg_mark_end(&sg[nsg - 1]); 2098 sg_mark_end(&sg[nsg - 1]);
2099 2099
2100 return nsg; 2100 return nsg;
2101} 2101}
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index eec02b29ffcf..d438dfb0c8f3 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1083,7 +1083,7 @@ static int tcp_v4_do_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key,
1083 sg_set_buf(&sg[block++], key->key, key->keylen); 1083 sg_set_buf(&sg[block++], key->key, key->keylen);
1084 nbytes += key->keylen; 1084 nbytes += key->keylen;
1085 1085
1086 __sg_mark_end(&sg[block - 1]); 1086 sg_mark_end(&sg[block - 1]);
1087 1087
1088 /* Now store the Hash into the packet */ 1088 /* Now store the Hash into the packet */
1089 err = crypto_hash_init(desc); 1089 err = crypto_hash_init(desc);
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 4b9032880959..06be2a1f2730 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -781,7 +781,7 @@ static int tcp_v6_do_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key,
781 sg_set_buf(&sg[block++], key->key, key->keylen); 781 sg_set_buf(&sg[block++], key->key, key->keylen);
782 nbytes += key->keylen; 782 nbytes += key->keylen;
783 783
784 __sg_mark_end(&sg[block - 1]); 784 sg_mark_end(&sg[block - 1]);
785 785
786 /* Now store the hash into the packet */ 786 /* Now store the hash into the packet */
787 err = crypto_hash_init(desc); 787 err = crypto_hash_init(desc);
diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
index c387cf68a08c..e09a95aa68ff 100644
--- a/net/rxrpc/rxkad.c
+++ b/net/rxrpc/rxkad.c
@@ -702,7 +702,7 @@ static void rxkad_sg_set_buf2(struct scatterlist sg[2],
702 nsg++; 702 nsg++;
703 } 703 }
704 704
705 __sg_mark_end(&sg[nsg - 1]); 705 sg_mark_end(&sg[nsg - 1]);
706 706
707 ASSERTCMP(sg[0].length + sg[1].length, ==, buflen); 707 ASSERTCMP(sg[0].length + sg[1].length, ==, buflen);
708} 708}
diff --git a/net/sunrpc/auth_gss/gss_krb5_crypto.c b/net/sunrpc/auth_gss/gss_krb5_crypto.c
index ab7cbd6575c4..0dd792338fa9 100644
--- a/net/sunrpc/auth_gss/gss_krb5_crypto.c
+++ b/net/sunrpc/auth_gss/gss_krb5_crypto.c
@@ -211,8 +211,8 @@ encryptor(struct scatterlist *sg, void *data)
211 if (thislen == 0) 211 if (thislen == 0)
212 return 0; 212 return 0;
213 213
214 __sg_mark_end(&desc->infrags[desc->fragno - 1]); 214 sg_mark_end(&desc->infrags[desc->fragno - 1]);
215 __sg_mark_end(&desc->outfrags[desc->fragno - 1]); 215 sg_mark_end(&desc->outfrags[desc->fragno - 1]);
216 216
217 ret = crypto_blkcipher_encrypt_iv(&desc->desc, desc->outfrags, 217 ret = crypto_blkcipher_encrypt_iv(&desc->desc, desc->outfrags,
218 desc->infrags, thislen); 218 desc->infrags, thislen);
@@ -293,7 +293,7 @@ decryptor(struct scatterlist *sg, void *data)
293 if (thislen == 0) 293 if (thislen == 0)
294 return 0; 294 return 0;
295 295
296 __sg_mark_end(&desc->frags[desc->fragno - 1]); 296 sg_mark_end(&desc->frags[desc->fragno - 1]);
297 297
298 ret = crypto_blkcipher_decrypt_iv(&desc->desc, desc->frags, 298 ret = crypto_blkcipher_decrypt_iv(&desc->desc, desc->frags,
299 desc->frags, thislen); 299 desc->frags, thislen);