OSDN Git Service

mtd: devices: m25p80: Make sure the buffer passed in op is DMA-able
authorBoris Brezillon <boris.brezillon@bootlin.com>
Mon, 17 Sep 2018 14:31:30 +0000 (16:31 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 29 Sep 2018 09:55:56 +0000 (02:55 -0700)
commitf11b8aad34fa7b0ec1ca2a45d2d2a826ebf41c32
treef36a274f9db4204689a00dd899e8ea6759f2f22c
parent1501a0f2e14ea7fc0028fe17eaa4a28231af7887
mtd: devices: m25p80: Make sure the buffer passed in op is DMA-able

commit 4a3e85f2674cbfb81052059107d0165269778e2f upstream.

As documented in spi-mem.h, spi_mem_op->data.buf.{in,out} must be
DMA-able, and commit 4120f8d158ef ("mtd: spi-nor: Use the spi_mem_xx()
API") failed to follow this rule as buffers passed to
->{read,write}_reg() are usually placed on the stack.

Fix that by allocating a scratch buffer and copying the data around.

Fixes: 4120f8d158ef ("mtd: spi-nor: Use the spi_mem_xx() API")
Reported-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Reviewed-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/mtd/devices/m25p80.c