Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mtd: spi-nor: Fix incorrect buffer access
For the Dual parallel mode, spi-nor layer doesn't have support to access odd flash addresses and the update is, if odd address is requested of len x with read buffer size of y, then decrement the address by one(which will give even address) and increment the length by 1(x+1) to access new extra byte. But we are not changing the size of the buffer, it is still y. Hence copying x+1 bytes of length to a buffer of size x will lead to stack corruption. There might be a chance of successful copy of data to that buffer even the size is x, if the memory we are accessing is still valid. But in stress kind of tests (ubi stress tests), which creates large buffers and because of the above bug, at some point of time we are getting the below error "Unable to handle kernel paging request at virtual address". The only way to catch this bug is through ubi stress test. As we are changing the address(odd to even) and length(x to x+1), we should also change the buffer size. hence allocate a buffer of size x+1 and free it when we are done with transfer. We don't create this buffer always, but if the address is odd and that to only in UBIFS case. Fixes: 0387834 ("spi: mtd: spi-nor: add ubifs support for dual-parallel") Signed-off-by: Naga Sureshkumar Relli <naga.sureshkumar.relli@xilinx.com> Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
- Loading branch information