linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] HID: intel-ish-hid: Fix -Wcast-function-type-strict in devm_ishtp_alloc_workqueue()
@ 2025-10-21 22:49 Nathan Chancellor
  2025-10-21 23:35 ` srinivas pandruvada
  2025-10-24 11:21 ` Jiri Kosina
  0 siblings, 2 replies; 4+ messages in thread
From: Nathan Chancellor @ 2025-10-21 22:49 UTC (permalink / raw)
  To: Srinivas Pandruvada, Jiri Kosina, Benjamin Tissoires, Zhang Lixu
  Cc: Kees Cook, linux-input, llvm, patches, 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.

Closes: https://github.com/ClangBuiltLinux/linux/issues/2139
Fixes: 0d30dae38fe0 ("HID: intel-ish-hid: Use dedicated unbound workqueues to prevent resume blocking")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/hid/intel-ish-hid/ipc/ipc.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/intel-ish-hid/ipc/ipc.c b/drivers/hid/intel-ish-hid/ipc/ipc.c
index 59355e4a61f8..abf9c9a31c39 100644
--- a/drivers/hid/intel-ish-hid/ipc/ipc.c
+++ b/drivers/hid/intel-ish-hid/ipc/ipc.c
@@ -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,
--  
Nathan Chancellor <nathan@kernel.org>


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] HID: intel-ish-hid: Fix -Wcast-function-type-strict in devm_ishtp_alloc_workqueue()
  2025-10-21 22:49 [PATCH] HID: intel-ish-hid: Fix -Wcast-function-type-strict in devm_ishtp_alloc_workqueue() Nathan Chancellor
@ 2025-10-21 23:35 ` srinivas pandruvada
  2025-10-22  0:57   ` Zhang, Lixu
  2025-10-24 11:21 ` Jiri Kosina
  1 sibling, 1 reply; 4+ messages in thread
From: srinivas pandruvada @ 2025-10-21 23:35 UTC (permalink / raw)
  To: Nathan Chancellor, Jiri Kosina, Benjamin Tissoires, Zhang Lixu
  Cc: Kees Cook, linux-input, llvm, patches

On Wed, 2025-10-22 at 00:49 +0200, Nathan Chancellor wrote:
> 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.
> 
> Closes: https://github.com/ClangBuiltLinux/linux/issues/2139
> Fixes: 0d30dae38fe0 ("HID: intel-ish-hid: Use dedicated unbound
> workqueues to prevent resume blocking")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>

Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

> ---
>  drivers/hid/intel-ish-hid/ipc/ipc.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hid/intel-ish-hid/ipc/ipc.c b/drivers/hid/intel-
> ish-hid/ipc/ipc.c
> index 59355e4a61f8..abf9c9a31c39 100644
> --- a/drivers/hid/intel-ish-hid/ipc/ipc.c
> +++ b/drivers/hid/intel-ish-hid/ipc/ipc.c
> @@ -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,
> --  
> Nathan Chancellor <nathan@kernel.org>
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] HID: intel-ish-hid: Fix -Wcast-function-type-strict in devm_ishtp_alloc_workqueue()
  2025-10-21 23:35 ` srinivas pandruvada
@ 2025-10-22  0:57   ` Zhang, Lixu
  0 siblings, 0 replies; 4+ messages in thread
From: Zhang, Lixu @ 2025-10-22  0:57 UTC (permalink / raw)
  To: srinivas pandruvada, Nathan Chancellor, Jiri Kosina,
	Benjamin Tissoires
  Cc: Kees Cook, linux-input@vger.kernel.org, llvm@lists.linux.dev,
	patches@lists.linux.dev

>-----Original Message-----
>From: srinivas pandruvada <srinivas.pandruvada@linux.intel.com>
>Sent: Wednesday, October 22, 2025 7:35 AM
>To: Nathan Chancellor <nathan@kernel.org>; Jiri Kosina <jikos@kernel.org>;
>Benjamin Tissoires <bentiss@kernel.org>; Zhang, Lixu <lixu.zhang@intel.com>
>Cc: Kees Cook <kees@kernel.org>; linux-input@vger.kernel.org;
>llvm@lists.linux.dev; patches@lists.linux.dev
>Subject: Re: [PATCH] HID: intel-ish-hid: Fix -Wcast-function-type-strict in
>devm_ishtp_alloc_workqueue()
>
>On Wed, 2025-10-22 at 00:49 +0200, Nathan Chancellor wrote:
>> 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.
>>
>> Closes: https://github.com/ClangBuiltLinux/linux/issues/2139
>> Fixes: 0d30dae38fe0 ("HID: intel-ish-hid: Use dedicated unbound
>> workqueues to prevent resume blocking")
>> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
>
>Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
>

Reviewed-by: Zhang Lixu <lixu.zhang@intel.com>

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] HID: intel-ish-hid: Fix -Wcast-function-type-strict in devm_ishtp_alloc_workqueue()
  2025-10-21 22:49 [PATCH] HID: intel-ish-hid: Fix -Wcast-function-type-strict in devm_ishtp_alloc_workqueue() Nathan Chancellor
  2025-10-21 23:35 ` srinivas pandruvada
@ 2025-10-24 11:21 ` Jiri Kosina
  1 sibling, 0 replies; 4+ messages in thread
From: Jiri Kosina @ 2025-10-24 11:21 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Srinivas Pandruvada, Benjamin Tissoires, Zhang Lixu, Kees Cook,
	linux-input, llvm, patches

On Wed, 22 Oct 2025, Nathan Chancellor wrote:

> 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.
> 
> Closes: https://github.com/ClangBuiltLinux/linux/issues/2139
> Fixes: 0d30dae38fe0 ("HID: intel-ish-hid: Use dedicated unbound workqueues to prevent resume blocking")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>

I have also added

	Reported-by: kernel test robot <lkp@intel.com>
	Closes: https://lore.kernel.org/oe-kbuild-all/202510190103.qTZvfdjj-lkp@intel.com/

and applied, thanks!

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-10-24 11:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-21 22:49 [PATCH] HID: intel-ish-hid: Fix -Wcast-function-type-strict in devm_ishtp_alloc_workqueue() Nathan Chancellor
2025-10-21 23:35 ` srinivas pandruvada
2025-10-22  0:57   ` Zhang, Lixu
2025-10-24 11:21 ` Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).