Skip to contentSkip to conversation

nouveau: fix function cast warning

PATCH Applied Arnd Bergmann 2 participants 2 messages Apr 4, 2024 – Apr 5, 2024

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

PATCH v2 1/1 nouveau: fix function cast warning

From: Arnd Bergmann <[email protected]>

Calling a function through an incompatible pointer type causes breaks kcfi, so clang warns about the assignment:

drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowof.c:73:10: error: cast from 'void (*)(const void *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
73 | .fini = (void(*)(void *))kfree,

Avoid this with a trivial wrapper.

Fixes c39f472e9f14 ("drm/nouveau: remove symlinks, move core/ to nvkm/ (no code changes)")

---
v2: avoid 'return kfree()' expression returning a void

---
 drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowof.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowof.c +6 -1
index 4bf486b57101..cb05f7f48a98 100644
@@ -66,11 +66,16 @@ of_init(struct nvkm_bios *bios, const char *name)
 	return ERR_PTR(-EINVAL);
 }
 
+static void of_fini(void *p)
+{
+	kfree(p);
+}
+
 const struct nvbios_source
 nvbios_of = {
 	.name = "OpenFirmware",
 	.init = of_init,
-	.fini = (void(*)(void *))kfree,
+	.fini = of_fini,
 	.read = of_read,
 	.size = of_size,
 	.rw = false,
Signature · 1 line
2.39.2
#1 lore raw
Quoted 5 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Calling a function through an incompatible pointer type causes breaks kcfi, so clang warns about the assignment:

Quoted 7 lines

drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowof.c:73:10: error: cast from 'void (*)(const void *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]

    73 |         .fini = (void(*)(void *))kfree,

Avoid this with a trivial wrapper.

Fixes c39f472e9f14 ("drm/nouveau: remove symlinks, move core/ to nvkm/ (no code changes)")

Applied to drm-misc-fixes, thanks!

Quoted 28 lines

---
v2: avoid 'return kfree()' expression returning a void

---
  drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowof.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowof.c +6 -1
index 4bf486b57101..cb05f7f48a98 100644
@@ -66,11 +66,16 @@ of_init(struct nvkm_bios *bios, const char *name)
  	return ERR_PTR(-EINVAL);
  }
 
+static void of_fini(void *p)
+{
+	kfree(p);
+}
+
  const struct nvbios_source
  nvbios_of = {
  	.name = "OpenFirmware",
  	.init = of_init,
-	.fini = (void(*)(void *))kfree,
+	.fini = of_fini,
  	.read = of_read,
  	.size = of_size,
  	.rw = false,