diff mbox series

[v2] nouveau: fix function cast warning

Message ID 20240404160234.2923554-1-arnd@kernel.org (mailing list archive)
State New, archived
Headers show
Series [v2] nouveau: fix function cast warning | expand

Commit Message

Arnd Bergmann April 4, 2024, 4:02 p.m. UTC
From: Arnd Bergmann <arnd@arndb.de>

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)")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
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(-)

Comments

Danilo Krummrich April 5, 2024, 4:37 p.m. UTC | #1
On 4/4/24 18:02, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> 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)")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied to drm-misc-fixes, thanks!

> ---
> 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(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowof.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowof.c
> index 4bf486b57101..cb05f7f48a98 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowof.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowof.c
> @@ -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,
diff mbox series

Patch

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowof.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowof.c
index 4bf486b57101..cb05f7f48a98 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowof.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowof.c
@@ -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,