]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit
spi: use sg_next for walking through the allocated scatterlist table
authorJuan Gutierrez <juan.gutierrez@nxp.com>
Mon, 21 Nov 2016 22:50:03 +0000 (16:50 -0600)
committerMark Brown <broonie@kernel.org>
Tue, 22 Nov 2016 16:27:31 +0000 (16:27 +0000)
commit8dd4a0163e7315d196e54780591b7426fa78e1fa
tree4ada86f84112b4644e5710d69033325db75ab356
parent1001354ca34179f3db924eb66672442a173147dc
spi: use sg_next for walking through the allocated scatterlist table

A null dereference or Oops exception might occurs when reading at once the
whole content of an spi-nor of big enough size that requires an scatterlist
table that does not fit into one single page.

The spi_map_buf function is ignoring the chained sg case by dereferenceing
the scatterlist elements in an array fashion. This wrongly assumes that
the allocation of the scatterlist elements are contiguous. This is true as
long as the scatterlist table fits within a PAGE_SIZE. However, for
allocation where the scatter table is bigger than that, the pages allocated
by sg_alloc might not be contigous.

The sg table can be properly walked by sg_next instead of using an array.

Signed-off-by: Juan Gutierrez <juan.gutierrez@nxp.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi.c