]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
firmware: dmi-id: add a release callback function
authorArnd Bergmann <arnd@arndb.de>
Mon, 8 Apr 2024 07:34:24 +0000 (09:34 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 16 Jun 2024 11:39:34 +0000 (13:39 +0200)
[ Upstream commit cf770af5645a41a753c55a053fa1237105b0964a ]

dmi_class uses kfree() as the .release function, but that now causes
a warning with clang-16 as it violates control flow integrity (KCFI)
rules:

drivers/firmware/dmi-id.c:174:17: error: cast from 'void (*)(const void *)' to 'void (*)(struct device *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
  174 |         .dev_release = (void(*)(struct device *)) kfree,

Add an explicit function to call kfree() instead.

Fixes: 4f5c791a850e ("DMI-based module autoloading")
Link: https://lore.kernel.org/lkml/20240213100238.456912-1-arnd@kernel.org/
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/firmware/dmi-id.c

index 940ddf916202afeb7e1c7ab71d635a2a58f4fb76..77a8d43e65d3c36570170856b214e995e141e30c 100644 (file)
@@ -169,9 +169,14 @@ static int dmi_dev_uevent(struct device *dev, struct kobj_uevent_env *env)
        return 0;
 }
 
+static void dmi_dev_release(struct device *dev)
+{
+       kfree(dev);
+}
+
 static struct class dmi_class = {
        .name = "dmi",
-       .dev_release = (void(*)(struct device *)) kfree,
+       .dev_release = dmi_dev_release,
        .dev_uevent = dmi_dev_uevent,
 };