mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
9p/virtio: fix off-by-one error in sg list bounds check
Because the value of limit is VIRTQUEUE_NUM, if index is equal to limit, it will cause sg array out of bounds, so correct the judgement of BUG_ON. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Yiwen Jiang <[email protected]> Reported-By: Dan Carpenter <[email protected]> Acked-by: Jun Piao <[email protected]> Cc: [email protected] Signed-off-by: Dominique Martinet <[email protected]>
This commit is contained in:
parent
c69f297d7f
commit
23cba9cbde
1 changed files with 2 additions and 1 deletions
|
|
@ -191,7 +191,7 @@ static int pack_sg_list(struct scatterlist *sg, int start,
|
|||
s = rest_of_page(data);
|
||||
if (s > count)
|
||||
s = count;
|
||||
BUG_ON(index > limit);
|
||||
BUG_ON(index >= limit);
|
||||
/* Make sure we don't terminate early. */
|
||||
sg_unmark_end(&sg[index]);
|
||||
sg_set_buf(&sg[index++], data, s);
|
||||
|
|
@ -236,6 +236,7 @@ pack_sg_list_p(struct scatterlist *sg, int start, int limit,
|
|||
s = PAGE_SIZE - data_off;
|
||||
if (s > count)
|
||||
s = count;
|
||||
BUG_ON(index >= limit);
|
||||
/* Make sure we don't terminate early. */
|
||||
sg_unmark_end(&sg[index]);
|
||||
sg_set_page(&sg[index++], pdata[i++], s, data_off);
|
||||
|
|
|
|||
Loading…
Reference in a new issue