Subject: CVE-2024-39484: mmc: davinci: Don't strip remove function when driver is builtin

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

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

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

mmc: davinci: Don't strip remove function when driver is builtin

Using __exit for the remove function results in the remove callback being
discarded with CONFIG_MMC_DAVINCI=y. When such a device gets unbound (e.g.
using sysfs or hotplug), the driver is just removed without the cleanup
being performed. This results in resource leaks. Fix it by compiling in the
remove callback unconditionally.

This also fixes a W=1 modpost warning:

WARNING: modpost: drivers/mmc/host/davinci_mmc: section mismatch in
reference: davinci_mmcsd_driver+0x10 (section: .data) ->
davinci_mmcsd_remove (section: .exit.text)

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

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

	Issue introduced in 2.6.33 with commit b4cff4549b7a and fixed in 5.10.221 with commit 6ff7cfa02baa
	Issue introduced in 2.6.33 with commit b4cff4549b7a and fixed in 5.15.162 with commit aea35157bb9b
	Issue introduced in 2.6.33 with commit b4cff4549b7a and fixed in 6.1.95 with commit 5ee241f72edc
	Issue introduced in 2.6.33 with commit b4cff4549b7a and fixed in 6.6.34 with commit 7590da4c04dd
	Issue introduced in 2.6.33 with commit b4cff4549b7a and fixed in 6.9.5 with commit 1d5ed0efe51d
	Issue introduced in 2.6.33 with commit b4cff4549b7a and fixed in 6.10 with commit 55c421b36448

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-39484
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/mmc/host/davinci_mmc.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/6ff7cfa02baabec907f6f29ea76634e6256d2ec4
	https://git.kernel.org/stable/c/aea35157bb9b825faa0432bd0f7fbea37ff39aa1
	https://git.kernel.org/stable/c/5ee241f72edc6dce5051a5f100eab6cc019d873e
	https://git.kernel.org/stable/c/7590da4c04dd4aa9c262da0231e978263861c6eb
	https://git.kernel.org/stable/c/1d5ed0efe51d36b9ae9b64f133bf41cdbf56f584
	https://git.kernel.org/stable/c/55c421b364482b61c4c45313a535e61ed5ae4ea3