lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <49bc1a59-1f5b-456b-aba4-be056d091e26@kernel.org>
Date: Wed, 12 Feb 2025 07:21:06 +0100
From: Jiri Slaby <jirislaby@...nel.org>
To: Stuart Hayhurst <stuart.a.hayhurst@...il.com>, linux-input@...r.kernel.org
Cc: Jiri Kosina <jikos@...nel.org>, Benjamin Tissoires <bentiss@...nel.org>,
 linux-kernel@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH v2] HID: corsair-void: Update power supply values with a
 unified work handler

On 11. 02. 25, 23:46, Stuart Hayhurst wrote:
> corsair_void_process_receiver can be called from an interrupt context,
> locking battery_mutex in it was causing a kernel panic.
> Fix it by moving the critical section into its own work, sharing this
> work with battery_add_work and battery_remove_work to remove the need
> for any locking
> 
> Closes: https://bugzilla.suse.com/show_bug.cgi?id=1236843
> 

No \n ^^ here.

> Fixes: 6ea2a6fd3872 ("HID: corsair-void: Add Corsair Void headset family driver")
> Cc: stable@...r.kernel.org
> Signed-off-by: Stuart Hayhurst <stuart.a.hayhurst@...il.com>
> ---
> --- a/drivers/hid/hid-corsair-void.c
> +++ b/drivers/hid/hid-corsair-void.c
...
> @@ -107,6 +105,10 @@
>   #define CORSAIR_VOID_SIDETONE_MAX_WIRELESS	55
>   #define CORSAIR_VOID_SIDETONE_MAX_WIRED		4096
>   
> +#define CORSAIR_VOID_ADD_BATTERY		BIT(0)
> +#define CORSAIR_VOID_REMOVE_BATTERY		BIT(1)
> +#define CORSAIR_VOID_UPDATE_BATTERY		BIT(2)

I would do an enum, but it's a matter of taste/preference.

> @@ -583,16 +565,48 @@ static void corsair_void_battery_add_work_handler(struct work_struct *work)
>   	drvdata->battery = new_supply;
>   }
>   
> +static void corsair_void_battery_work_handler(struct work_struct *work)
> +{
> +	struct corsair_void_drvdata *drvdata = container_of(work,
> +		struct corsair_void_drvdata, battery_work);
> +
> +	bool add_battery = test_and_clear_bit(CORSAIR_VOID_ADD_BATTERY,
> +					      &drvdata->battery_work_flags);
> +	bool remove_battery = test_and_clear_bit(CORSAIR_VOID_REMOVE_BATTERY,
> +						 &drvdata->battery_work_flags);
> +	bool update_battery = test_and_clear_bit(CORSAIR_VOID_UPDATE_BATTERY,
> +						 &drvdata->battery_work_flags);
> +
> +	/* Add, remove or skip battery */

What is to skip a battery? Anyway, the comments here seem to be 
superfluous as the code is obvious™.

> +	if (add_battery && !remove_battery) {
> +		corsair_void_add_battery(drvdata);
> +	} else if (remove_battery && !add_battery) {
> +		if (drvdata->battery) {

Perhaps '&& drvdata->battery' instead of the nested 'if'?

> +			power_supply_unregister(drvdata->battery);
> +			drvdata->battery = NULL;
> +		}
> +	}
> +
> +	/* Communicate that battery values changed */
> +	if (update_battery) {
> +		if (drvdata->battery)

Ditto.

> +			power_supply_changed(drvdata->battery);
> +	}
> +
> +}

Overall, LGTM.

thanks,
-- 
js
suse labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ