From: Geert Uytterhoeven geert+renesas@glider.be
[ Upstream commit d1dfcdd30140c031ae091868fb5bed084132bca1 ]
As described in the added code comment, a reference to .exit.text is ok for drivers registered via platform_driver_probe(). Make this explicit to prevent the following section mismatch warning
WARNING: modpost: drivers/pcmcia/omap_cf: section mismatch in reference: omap_cf_driver+0x4 (section: .data) -> omap_cf_remove (section: .exit.text)
that triggers on an omap1_defconfig + CONFIG_OMAP_CF=m build.
Signed-off-by: Geert Uytterhoeven geert+renesas@glider.be Acked-by: Aaro Koskinen aaro.koskinen@iki.fi Reviewed-by: Uwe Kleine-König u.kleine-koenig@baylibre.com Signed-off-by: Dominik Brodowski linux@dominikbrodowski.net Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
Based on my thorough analysis, I can now provide a definitive answer about whether this commit should be backported to stable kernel trees.
## Backport Status: **YES**
## Extensive Analysis:
This commit should be backported to stable kernel trees for the following reasons:
### 1. **Fixes a legitimate build warning** The commit addresses a section mismatch warning that occurs during kernel build with `CONFIG_OMAP_CF=m`: ``` WARNING: modpost: drivers/pcmcia/omap_cf: section mismatch in reference: omap_cf_driver+0x4 (section: .data) -> omap_cf_remove (section: .exit.text) ```
### 2. **Follows established kernel patterns** The fix uses the `__refdata` annotation, which is the standard solution for this specific pattern where: - The driver uses `platform_driver_probe()` (line 315 in omap_cf.c) - The remove function is marked with `__exit` (line 293: `static void __exit omap_cf_remove`) - The driver struct references the remove function via `__exit_p()` (line 309)
### 3. **Identical to recently accepted fixes** Commit 50133cf052631 ("scsi: sun3: Mark driver struct with __refdata to prevent section mismatch") from November 2024 shows the exact same fix pattern was recently accepted. The commit messages are nearly identical, both authored by Geert Uytterhoeven, and both address the same type of warning.
### 4. **Meets stable kernel criteria** According to Documentation/process/stable-kernel-rules.rst: - **Size**: The change is minimal (1 line of actual code change plus comment) - **Correctness**: The fix is obviously correct - `platform_driver_probe()` ensures the driver cannot be unbound at runtime, making the reference to `.exit.text` safe - **Bug category**: Falls under "build error" which is explicitly mentioned as acceptable (line 19: "a build error") - **Testing**: Has been reviewed by Uwe Kleine-König, a kernel developer with expertise in this area
### 5. **Safe and low-risk change** The change only affects compile-time section placement and modpost warnings. It has zero runtime impact: - For built-in drivers: `.exit.text` sections are discarded entirely, so the reference is harmless - For modular drivers: The reference is safe because `platform_driver_probe()` prevents runtime unbinding
### 6. **Prevents potential build failures** While currently a warning, section mismatches can: - Be promoted to errors with certain kernel configurations - Cause confusion for developers and automated build systems - Mask other legitimate issues in build logs
### 7. **Driver-specific context** The omap_cf driver is for OMAP 16xx CompactFlash controller, used in legacy TI OMAP1 platforms. While these are older systems, they are still maintained in the kernel, and build warnings should be fixed to maintain code quality.
### Code Analysis Details: The commit adds the `__refdata` annotation at line 305: ```c +static struct platform_driver omap_cf_driver __refdata = { ```
This explicitly tells the kernel's section mismatch checker that this reference pattern is intentional and safe. The added comment clearly documents why this is necessary, improving code maintainability.
### Conclusion: This is a textbook example of a stable-appropriate fix: minimal, obvious, fixes a real build issue, follows established patterns, and has been validated by the same fix being applied to similar drivers. The change improves build cleanliness without any risk of runtime regression.
drivers/pcmcia/omap_cf.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c index 1b1dff56ec7b1..733777367c3b4 100644 --- a/drivers/pcmcia/omap_cf.c +++ b/drivers/pcmcia/omap_cf.c @@ -302,7 +302,13 @@ static void __exit omap_cf_remove(struct platform_device *pdev) kfree(cf); }
-static struct platform_driver omap_cf_driver = { +/* + * omap_cf_remove() lives in .exit.text. For drivers registered via + * platform_driver_probe() this is ok because they cannot get unbound at + * runtime. So mark the driver struct with __refdata to prevent modpost + * triggering a section mismatch warning. + */ +static struct platform_driver omap_cf_driver __refdata = { .driver = { .name = driver_name, },