• Benoît Thébaudeau's avatar
    fs/fat/fat_write: Fix buffer alignments · 8133f43d
    Benoît Thébaudeau authored
    set_cluster() was using a temporary buffer without enforcing its
    alignment for DMA and cache. Moreover, it did not check the alignment of
    the passed buffer, which can come directly from applicative code or from
    the user.
    
    This could cause random data corruption, which has been observed on
    i.MX25 writing to an SD card.
    
    Fix this by only passing ARCH_DMA_MINALIGN-aligned buffers to
    disk_write(), which requires the introduction of a buffer bouncing
    mechanism for the misaligned buffers passed to set_cluster().
    
    By the way, improve the handling of the corresponding return values from
    disk_write():
     - print them with debug() in case of error,
     - consider that there is an error is disk_write() returns a smaller
       block count than the requested one, not only if its return value is
       negative.
    
    After this change, set_cluster() and get_cluster() are almost
    symmetrical.
    Signed-off-by: default avatarBenoît Thébaudeau <benoit@wsystem.com>
    8133f43d
Name
Last commit
Last update
Licenses Loading commit data...
api Loading commit data...
arch Loading commit data...
board Loading commit data...
common Loading commit data...
configs Loading commit data...
disk Loading commit data...
doc Loading commit data...
drivers Loading commit data...
dts Loading commit data...
examples Loading commit data...
fs Loading commit data...
include Loading commit data...
lib Loading commit data...
net Loading commit data...
post Loading commit data...
scripts Loading commit data...
test Loading commit data...
tools Loading commit data...
.checkpatch.conf Loading commit data...
.gitignore Loading commit data...
.mailmap Loading commit data...
.travis.yml Loading commit data...
Kbuild Loading commit data...
Kconfig Loading commit data...
MAINTAINERS Loading commit data...
MAKEALL Loading commit data...
Makefile Loading commit data...
README Loading commit data...
config.mk Loading commit data...
snapshot.commit Loading commit data...