Skip to contentSkip to conversation

HID: intel-ish-hid: Fix -Wcast-function-type-strict in devm_ishtp_alloc_workqueue()

PATCH In review Nathan Chancellor 4 participants 4 messages Oct 21, 2025 – Oct 24, 2025

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

PATCH 1/1 HID: intel-ish-hid: Fix -Wcast-function-type-strict in devm_ishtp_alloc_workqueue()

Clang warns (or errors with CONFIG_WERROR=y / W=e):

drivers/hid/intel-ish-hid/ipc/ipc.c:935:36: error: cast from 'void (*)(struct workqueue_struct *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
935 | if (devm_add_action_or_reset(dev, (void (*)(void *))destroy_workqueue,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/device/devres.h:168:34: note: expanded from macro 'devm_add_action_or_reset'
168 | __devm_add_action_or_ireset(dev, action, data, #action)
| ^~~~~~

This warning is pointing out a kernel control flow integrity (kCFI / CONFIG_CFI=y) violation will occur due to this function cast when the destroy_workqueue() is indirectly called via devm_action_release() because the prototype of destroy_workqueue() does not match the prototype of (*action)().

Use a local function with the correct prototype to wrap destroy_workqueue() to resolve the warning and CFI violation.

Fixes 0d30dae38fe0 ("HID: intel-ish-hid: Use dedicated unbound workqueues to prevent resume blocking")
---
 drivers/hid/intel-ish-hid/ipc/ipc.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/hid/intel-ish-hid/ipc/ipc.c +6 -2
index 59355e4a61f8..abf9c9a31c39 100644
@@ -924,6 +924,11 @@ static const struct ishtp_hw_ops ish_hw_ops = {
 	.dma_no_cache_snooping = _dma_no_cache_snooping
 };
 
+static void ishtp_free_workqueue(void *wq)
+{
+	destroy_workqueue(wq);
+}
+
 static struct workqueue_struct *devm_ishtp_alloc_workqueue(struct device *dev)
 {
 	struct workqueue_struct *wq;
@@ -932,8 +937,7 @@ static struct workqueue_struct *devm_ishtp_alloc_workqueue(struct device *dev)
 	if (!wq)
 		return NULL;
 
-	if (devm_add_action_or_reset(dev, (void (*)(void *))destroy_workqueue,
-				     wq))
+	if (devm_add_action_or_reset(dev, ishtp_free_workqueue, wq))
 		return NULL;
 
 	return wq;

---
base-commit: 828aeac92901c1f31b51ae0b9d792b9af5bd3e27
change-id: 20251021-ishtp-fix-function-cast-warn-660d3dae8af4

Best regards,

Signature · 1 line
Nathan Chancellor <[email protected]>
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 21 lines · Nathan Chancellor

Clang warns (or errors with CONFIG_WERROR=y / W=e):

  drivers/hid/intel-ish-hid/ipc/ipc.c:935:36: error: cast from 'void (*)(struct workqueue_struct *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict] 935 |         if (devm_add_action_or_reset(dev, (void (*)(void *))destroy_workqueue,
        |
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/device/devres.h:168:34: note: expanded from macro 'devm_add_action_or_reset'
    168 |         __devm_add_action_or_ireset(dev, action, data, #action)
        |                                         ^~~~~~

This warning is pointing out a kernel control flow integrity (kCFI / CONFIG_CFI=y) violation will occur due to this function cast when the destroy_workqueue() is indirectly called via devm_action_release() because the prototype of destroy_workqueue() does not match the prototype of (*action)().

Quoted 7 lines

Use a local function with the correct prototype to wrap destroy_workqueue() to resolve the warning and CFI violation.

Fixes 0d30dae38fe0 ("HID: intel-ish-hid: Use dedicated unbound

workqueues to prevent resume blocking")

Quoted 43 lines

---
 drivers/hid/intel-ish-hid/ipc/ipc.c | 8 ++++++--

 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/hid/intel- renamed from drivers/hid/intel-ish-hid/ipc/ipc.c +0 -0

ish-hid/ipc/ipc.c
index 59355e4a61f8..abf9c9a31c39 100644

drivers/hid/intel-ish-hid/ipc/ipc.c +0 -0
@@ -924,6 +924,11 @@ static const struct ishtp_hw_ops ish_hw_ops = {

  .dma_no_cache_snooping = _dma_no_cache_snooping };

drivers/hid/intel-ish-hid/ipc/ipc.c +5 -0
+static void ishtp_free_workqueue(void *wq)
+{
+	destroy_workqueue(wq);
+}
+

 static struct workqueue_struct *devm_ishtp_alloc_workqueue(struct device *dev)
 {
  struct workqueue_struct *wq;

drivers/hid/intel-ish-hid/ipc/ipc.c +0 -0
@@ -932,8 +937,7 @@ static struct workqueue_struct
 *devm_ishtp_alloc_workqueue(struct device *dev)
  	if (!wq)
  		return NULL;

drivers/hid/intel-ish-hid/ipc/ipc.c +0 -1
-	if (devm_add_action_or_reset(dev, (void (*)(void

*))destroy_workqueue,

drivers/hid/intel-ish-hid/ipc/ipc.c +1 -1
-				     wq))
+	if (devm_add_action_or_reset(dev, ishtp_free_workqueue, wq))

  return NULL;

  return wq;

---
base-commit: 828aeac92901c1f31b51ae0b9d792b9af5bd3e27
change-id: 20251021-ishtp-fix-function-cast-warn-660d3dae8af4

Best regards,
--
Nathan Chancellor <[email protected]>

Reviewed-by
#2 lore raw
Quoted 34 lines

-----Original Message-----
From: srinivas pandruvada <[email protected]>
Sent: Wednesday, October 22, 2025 7:35 AM
To: Nathan Chancellor <[email protected]>; Jiri Kosina <[email protected]>; Benjamin Tissoires <[email protected]>; Zhang, Lixu <[email protected]>
Cc: Kees Cook <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] HID: intel-ish-hid: Fix -Wcast-function-type-strict in devm_ishtp_alloc_workqueue()

Quoted 23 lines · Nathan Chancellor

Clang warns (or errors with CONFIG_WERROR=y / W=e):

  drivers/hid/intel-ish-hid/ipc/ipc.c:935:36: error: cast from 'void (*)(struct workqueue_struct *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict] 935 |         if (devm_add_action_or_reset(dev, (void (*)(void *))destroy_workqueue,
        | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/device/devres.h:168:34: note: expanded from macro 'devm_add_action_or_reset'
    168 |         __devm_add_action_or_ireset(dev, action, data, #action)
        |                                         ^~~~~~

This warning is pointing out a kernel control flow integrity (kCFI / CONFIG_CFI=y) violation will occur due to this function cast when the destroy_workqueue() is indirectly called via devm_action_release() because the prototype of destroy_workqueue() does not match the prototype of (*action)().

Use a local function with the correct prototype to wrap destroy_workqueue() to resolve the warning and CFI violation.

Quoted 7 lines
Quoted 4 lines
Fixes 0d30dae38fe0 ("HID: intel-ish-hid: Use dedicated unbound

workqueues to prevent resume blocking")

Quoted 2 lines
Quoted 2 lines

---
 drivers/hid/intel-ish-hid/ipc/ipc.c | 8 ++++++--

maintainer
#3 lore raw
In reply to Nathan Chancellor
Quoted 15 lines · Nathan Chancellor

Clang warns (or errors with CONFIG_WERROR=y / W=e):

drivers/hid/intel-ish-hid/ipc/ipc.c:935:36: error: cast from 'void (*)(struct workqueue_struct *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
935 | if (devm_add_action_or_reset(dev, (void (*)(void *))destroy_workqueue,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/device/devres.h:168:34: note: expanded from macro 'devm_add_action_or_reset'
168 | __devm_add_action_or_ireset(dev, action, data, #action)
| ^~~~~~

This warning is pointing out a kernel control flow integrity (kCFI / CONFIG_CFI=y) violation will occur due to this function cast when the destroy_workqueue() is indirectly called via devm_action_release() because the prototype of destroy_workqueue() does not match the prototype of (*action)().

Quoted 6 lines

Use a local function with the correct prototype to wrap destroy_workqueue() to resolve the warning and CFI violation.

Fixes 0d30dae38fe0 ("HID: intel-ish-hid: Use dedicated unbound workqueues to prevent resume blocking")

I have also added

	Reported-by: kernel test robot <[email protected]>
	Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

and applied, thanks!

Signature · 2 lines
Jiri Kosina
SUSE Labs