spi: Fix mapping from vmalloc-ed buffer to scatter list
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Mon, 17 Nov 2014 09:14:31 +0000 (09:14 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 6 Dec 2014 23:57:30 +0000 (15:57 -0800)
commit2f5dbae2894829b607ac5c0558e3ae0b34f8a8c7
treedc8c823e8fa9caaa8a1106d0f154fe4ad88a251b
parent29d04b78c896725f55c0dc4c3a23eba18a545c73
spi: Fix mapping from vmalloc-ed buffer to scatter list

commit c1aefbdd050e1fb15e92bcaf34d95b17ea952097 upstream.

We can only use page_address on memory that has been mapped using kmap,
when the buffer passed to the SPI has been allocated by vmalloc the page
has not necessarily been mapped through kmap. This means sometimes
page_address will return NULL causing the pointer we pass to sg_set_buf
to be invalid.

As we only call page_address so that we can pass a virtual address to
sg_set_buf which will then immediately call virt_to_page on it, fix this
by calling sg_set_page directly rather then relying on the sg_set_buf
helper.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/spi/spi.c