• Paul Kocialkowski's avatar
    i2c: bcm2835: Clear current buffer pointers and counts after a transfer · f275a465
    Paul Kocialkowski authored
    The driver's interrupt handler checks whether a message is currently
    being handled with the curr_msg pointer. When it is NULL, the interrupt
    is considered to be unexpected. Similarly, the i2c_start_transfer
    routine checks for the remaining number of messages to handle in
    num_msgs.
    
    However, these values are never cleared and always keep the message and
    number relevant to the latest transfer (which might be done already and
    the underlying message memory might have been freed).
    
    When an unexpected interrupt hits with the DONE bit set, the isr will
    then try to access the flags field of the curr_msg structure, leading
    to a fatal page fault.
    
    The msg_buf and msg_buf_remaining fields are also never cleared at the
    end of the transfer, which can lead to similar pitfalls.
    
    Fix these issues by introducing a cleanup function and always calling
    it after a transfer is finished.
    
    Fixes: e2474541 ("i2c: bcm2835: Fix hang for writing messages larger than 16 bytes")
    Signed-off-by: Paul Kocialkowski's avatarPaul Kocialkowski <paul.kocialkowski@bootlin.com>
    Acked-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
    Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
    f275a465
Name
Last commit
Last update
..
algos Loading commit data...
busses Loading commit data...
muxes Loading commit data...
Kconfig Loading commit data...
Makefile Loading commit data...
i2c-boardinfo.c Loading commit data...
i2c-core-acpi.c Loading commit data...
i2c-core-base.c Loading commit data...
i2c-core-of.c Loading commit data...
i2c-core-slave.c Loading commit data...
i2c-core-smbus.c Loading commit data...
i2c-core.h Loading commit data...
i2c-dev.c Loading commit data...
i2c-mux.c Loading commit data...
i2c-slave-eeprom.c Loading commit data...
i2c-smbus.c Loading commit data...
i2c-stub.c Loading commit data...