Skip to content

Commit ac4e97a

Browse files
rustyrussellaxboe
authored andcommitted
scatterlist: sg_set_buf() argument must be in linear mapping
Add a check behind CONFIG_DEBUG_SG to verify this. Signed-off-by: Rusty Russell <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 4997b72 commit ac4e97a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

include/linux/scatterlist.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ static inline struct page *sg_page(struct scatterlist *sg)
111111
static inline void sg_set_buf(struct scatterlist *sg, const void *buf,
112112
unsigned int buflen)
113113
{
114+
#ifdef CONFIG_DEBUG_SG
115+
BUG_ON(!virt_addr_valid(buf));
116+
#endif
114117
sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf));
115118
}
116119

0 commit comments

Comments
 (0)