• Wolfram Sang's avatar
    i2c: rcar: avoid race when unregistering slave · c7c9e914
    Wolfram Sang authored
    Due to the lockless design of the driver, it is theoretically possible
    to access a NULL pointer, if a slave interrupt was running while we were
    unregistering the slave. To make this rock solid, disable the interrupt
    for a short time while we are clearing the interrupt_enable register.
    This patch is purely based on code inspection. The OOPS is super-hard to
    trigger because clearing SAR (the address) makes interrupts even more
    unlikely to happen as well. While here, reinit SCR to SDBS because this
    bit should always be set according to documentation. There is no effect,
    though, because the interface is disabled.
    
    Fixes: 7b814d85 ("i2c: rcar: avoid race when unregistering slave client")
    Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
    Reviewed-by: default avatarNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
    Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
    c7c9e914
i2c-rcar.c 27.3 KB