Skip to content

Commit a497816

Browse files
committed
eeprom: at24: fix memory corruption race condition
jira LE-1907 cve CVE-2024-35848 Rebuild_History Non-Buildable kernel-5.14.0-427.31.1.el9_4 commit-author Daniel Okazaki <dtokazaki@google.com> commit f42c970 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: b20eb4c ("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> (cherry picked from commit f42c970) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 036691d commit a497816

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

drivers/misc/eeprom/at24.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -781,15 +781,6 @@ static int at24_probe(struct i2c_client *client)
781781
}
782782
pm_runtime_enable(dev);
783783

784-
at24->nvmem = devm_nvmem_register(dev, &nvmem_config);
785-
if (IS_ERR(at24->nvmem)) {
786-
pm_runtime_disable(dev);
787-
if (!pm_runtime_status_suspended(dev))
788-
regulator_disable(at24->vcc_reg);
789-
return dev_err_probe(dev, PTR_ERR(at24->nvmem),
790-
"failed to register nvmem\n");
791-
}
792-
793784
/*
794785
* Perform a one-byte test read to verify that the chip is functional,
795786
* unless powering on the device is to be avoided during probe (i.e.
@@ -805,6 +796,15 @@ static int at24_probe(struct i2c_client *client)
805796
}
806797
}
807798

799+
at24->nvmem = devm_nvmem_register(dev, &nvmem_config);
800+
if (IS_ERR(at24->nvmem)) {
801+
pm_runtime_disable(dev);
802+
if (!pm_runtime_status_suspended(dev))
803+
regulator_disable(at24->vcc_reg);
804+
return dev_err_probe(dev, PTR_ERR(at24->nvmem),
805+
"failed to register nvmem\n");
806+
}
807+
808808
/* If this a SPD EEPROM, probe for DDR3 thermal sensor */
809809
if (cdata == &at24_data_spd)
810810
at24_probe_temp_sensor(client);

0 commit comments

Comments
 (0)