• Juan Gutierrez's avatar
    spi: use sg_next for walking through the allocated scatterlist table · 8dd4a016
    Juan Gutierrez authored
    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: default avatarJuan Gutierrez <juan.gutierrez@nxp.com>
    Signed-off-by: default avatarMark Brown <broonie@kernel.org>
    8dd4a016
spi.c 87.7 KB