linux-stable/drivers/i2c
Wolfram Sang 104f1552c1 i2c: rcar: avoid race when unregistering slave
[ Upstream commit c7c9e914f9 ]

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: 7b814d852a ("i2c: rcar: avoid race when unregistering slave client")
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-08-21 09:48:21 +02:00
..
algos i2c: algo-pca: Add 0x78 as SCL stuck low status for PCA9665 2020-07-09 09:36:31 +02:00
busses i2c: rcar: avoid race when unregistering slave 2020-08-21 09:48:21 +02:00
muxes i2c: mux: demux-pinctrl: Fix an error handling path in 'i2c_demux_pinctrl_probe()' 2020-05-27 16:42:52 +02:00
i2c-boardinfo.c i2c: i2c-boardinfo: fix memory leaks on devinfo 2018-02-03 17:39:07 +01:00
i2c-core-acpi.c i2c: acpi: put device when verifying client fails 2020-03-20 10:54:20 +01:00
i2c-core-base.c i2c/mux, locking/core: Annotate the nested rt_mutex usage 2018-09-05 09:26:29 +02:00
i2c-core-of.c i2c: core: fix use after free in of_i2c_notify 2019-12-17 20:37:32 +01:00
i2c-core-slave.c i2c: slave: add sanity check when unregistering 2020-08-21 09:47:59 +02:00
i2c-core-smbus.c i2c: core-smbus: prevent stack corruption on read I2C_BLOCK_DATA 2018-01-23 19:58:17 +01:00
i2c-core.h i2c: core: Allow empty id_table in ACPI case as well 2017-07-31 15:50:33 +02:00
i2c-dev.c i2c: dev: Fix the race between the release of i2c_dev and cdev 2020-05-27 16:42:50 +02:00
i2c-mux.c i2c/mux, locking/core: Annotate the nested rt_mutex usage 2018-09-05 09:26:29 +02:00
i2c-slave-eeprom.c
i2c-smbus.c
i2c-stub.c
Kconfig
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00