]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
eeprom: at24: fix memory corruption race condition
authorDaniel Okazaki <dtokazaki@google.com>
Mon, 22 Apr 2024 17:43:36 +0000 (17:43 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 May 2024 14:35:28 +0000 (16:35 +0200)
commit6d8b56ec0c8f30d5657382f47344a32569f7a9bc
tree515841a3adb3b6507cfa87049a26d74466d30f1c
parentfd8547ebc187037cc69441a15c1441aeaab80f49
eeprom: at24: fix memory corruption race condition

commit f42c97027fb75776e2e9358d16bf4a99aeb04cf2 upstream.

If the eeprom is not accessible, an nvmem device will be registered, the
read will fail, and the device will be torn down. If another driver
accesses the nvmem device after the teardown, it will reference
invalid memory.

Move the failure point before registering the nvmem device.

Signed-off-by: Daniel Okazaki <dtokazaki@google.com>
Fixes: b20eb4c1f026 ("eeprom: at24: drop unnecessary label")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20240422174337.2487142-1-dtokazaki@google.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/eeprom/at24.c