Subject: CVE-2024-35848: eeprom: at24: fix memory corruption race condition

From: Greg Kroah-Hartman <[email-masked]>

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

eeprom: at24: fix memory corruption race condition

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.

The Linux kernel CVE team has assigned CVE-2024-35848 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 5.3 with commit b20eb4c1f026 and fixed in 5.10.217 with commit c850f71fca09
	Issue introduced in 5.3 with commit b20eb4c1f026 and fixed in 5.15.159 with commit 26d32bec4c6d
	Issue introduced in 5.3 with commit b20eb4c1f026 and fixed in 6.1.91 with commit c43e5028f5a3
	Issue introduced in 5.3 with commit b20eb4c1f026 and fixed in 6.6.31 with commit 2af84c46b9b8
	Issue introduced in 5.3 with commit b20eb4c1f026 and fixed in 6.8.9 with commit 6d8b56ec0c8f
	Issue introduced in 5.3 with commit b20eb4c1f026 and fixed in 6.9 with commit f42c97027fb7

Please see https://www.kernel.org for a full list of currently supported
kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to
older supported kernel versions.  The official CVE entry at
	https://cve.org/CVERecord/?id=CVE-2024-35848
will be updated if fixes are backported, please check that for the most
up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
	drivers/misc/eeprom/at24.c

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest
stable kernel version for this, and many other bugfixes.  Individual
changes are never tested alone, but rather are part of a larger kernel
release.  Cherry-picking individual commits is not recommended or
supported by the Linux kernel community at all.  If however, updating to
the latest release is impossible, the individual changes to resolve this
issue can be found at these commits:
	https://git.kernel.org/stable/c/c850f71fca09ea41800ed55905980063d17e01da
	https://git.kernel.org/stable/c/26d32bec4c6d255a03762f33c637bfa3718be15a
	https://git.kernel.org/stable/c/c43e5028f5a35331eb25017f5ff6cc21735005c6
	https://git.kernel.org/stable/c/2af84c46b9b8f2d6c0f88d09ee5c849ae1734676
	https://git.kernel.org/stable/c/6d8b56ec0c8f30d5657382f47344a32569f7a9bc
	https://git.kernel.org/stable/c/f42c97027fb75776e2e9358d16bf4a99aeb04cf2