Re: [PATCH 3/5] platform/x86: hp-wmi: handle errors in the OMEN key event

Ilpo Järvinen <[email protected]>
Newsgroups org.kernel.vger.platform-driver-x86,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Thu, 16 Jul 2026, Emre Cecanpunar wrote:

> hp_wmi_read_int() can return a negative error code, but the
> HPWMI_OMEN_KEY handler passes it directly to
> sparse_keymap_report_event(). The value is then converted to an unsigned
> key code, causing a bogus lookup and a KEY_UNKNOWN input event.
> 
> Stop processing the event when reading the key code fails, mirroring the
> existing check in the HPWMI_BEZEL_BUTTON handler.
> 
> Fixes: f4a31a428d0d ("platform/x86: hp-wmi: Add HP Envy special key support")
> Signed-off-by: Emre Cecanpunar <[email protected]>
> ---
>  drivers/platform/x86/hp/hp-wmi.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
> index e226b772ef00..29881749aae6 100644
> --- a/drivers/platform/x86/hp/hp-wmi.c
> +++ b/drivers/platform/x86/hp/hp-wmi.c
> @@ -1253,10 +1253,14 @@ static void hp_wmi_notify(union acpi_object *obj, void *context)
>  		platform_profile_cycle();
>  		break;
>  	case HPWMI_OMEN_KEY:
> -		if (event_data) /* Only should be true for HP Omen */
> +		if (event_data) {
> +			/* Only should be true for HP Omen */

Moving the comment here causes it no longer make any sense because "true" 
related to the if check.

>  			key_code = event_data;
> -		else
> +		} else {
>  			key_code = hp_wmi_read_int(HPWMI_HOTKEY_QUERY);
> +			if (key_code < 0)
> +				break;
> +		}
>  
>  		if (!sparse_keymap_report_event(hp_wmi_input_dev,
>  						key_code, 1, true))
> 

-- 
 i.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.