Skip to contentSkip to conversation

i2c: i801: Annotate apanel_addr as __ro_after_init

PATCH Applied Heiner Kallweit 3 participants 7 messages Apr 12, 2024 – Apr 16, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: i801: Annotate apanel_addr as __ro_after_init

Annotate this variable as __ro_after_init to protect it from being overwritten later.

---
 drivers/i2c/busses/i2c-i801.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-i801.c +1 -1
index 6d027a77d..e577abc77 100644
@@ -1060,7 +1060,7 @@ static const struct pci_device_id i801_ids[] = {
 MODULE_DEVICE_TABLE(pci, i801_ids);
 
 #if defined CONFIG_X86 && defined CONFIG_DMI
-static unsigned char apanel_addr;
+static unsigned char apanel_addr __ro_after_init;
 
 /* Scan the system ROM for the signature "FJKEYINF" */
 static __init const void __iomem *bios_signature(const void __iomem *bios)
Signature · 1 line
2.44.0
#1 lore raw
Quoted 1 line

#if defined CONFIG_X86 && defined CONFIG_DMI

Shouldn't that be on top of "[PATCH v2] i2c: i801: Fix missing Kconfig dependency" which Andi already merged?

#2 lore raw
Quoted 5 lines · Wolfram Sang
Quoted 1 line

#if defined CONFIG_X86 && defined CONFIG_DMI

Shouldn't that be on top of "[PATCH v2] i2c: i801: Fix missing Kconfig dependency" which Andi already merged?

No, this is a different code part here. The other one was protected with:
#if IS_ENABLED(CONFIG_I2C_MUX_GPIO) && defined CONFIG_DMI

#3 lore raw
Quoted 2 lines

No, this is a different code part here. The other one was

Oh. Sorry for the noise!

maintainer
#4 lore raw
In reply to Heiner Kallweit

Hi Heiner,

Quoted 2 lines · Heiner Kallweit

Annotate this variable as __ro_after_init to protect it from being overwritten later.

What is the reason behind this patch? Where is the risk of overwriting this variable?

Andi

#5 lore raw
Quoted 9 lines · Andi Shyti

Hi Heiner,

Quoted 2 lines · Heiner Kallweit

Annotate this variable as __ro_after_init to protect it from being overwritten later.

What is the reason behind this patch? Where is the risk of overwriting this variable?

The annotation makes clear that this variable is to be written by init code only, w/o having to check all usage in the driver. Currently the variable isn't written later, however the annotation protects from any such potential attempt in the future. The original commit message has more arguments for using this annotation. https://lwn.net/Articles/676145/

Quoted 1 line

Andi

Heiner

maintainer Applied
#6 lore raw
In reply to Heiner Kallweit

Hi

Quoted 4 lines · Heiner Kallweit

Annotate this variable as __ro_after_init to protect it from being overwritten later.

Applied to i2c/i2c-host on

git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git

Thank you,
Andi

Patches applied
===============
[1/1] i2c: i801: Annotate apanel_addr as __ro_after_init

      commit: 08944c074592041873f1cb3e5be5fc3fd4cdc3ad