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:
 <PN3PR01MB959796A52701ACD2703157B1B846A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM>
Date: Mon, 30 Jun 2025 15:40:47 +0530
From: Aditya Garg <gargaditya08@...e.com>
To: José Expósito <jose.exposito89@...il.com>
Cc: Jiri Kosina <jikos@...nel.org>, Benjamin Tissoires <bentiss@...nel.org>,
 linux-input@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] HID: apple: avoid setting up battery timer for
 devices without battery



On 30-06-2025 03:03 pm, José Expósito wrote:
> On Wed, Jun 25, 2025 at 07:46:03PM +0530, Aditya Garg wrote:
>> Currently, the battery timer is set up for all devices using hid-apple,
>> irrespective of whether they actually have a battery or not.
>>
>> APPLE_RDESC_BATTERY is a quirk that indicates the device has a battery
>> and needs the battery timer. This patch checks for this quirk before
>> setting up the timer, ensuring that only devices with a battery will
>> have the timer set up.
>>
>> Fixes: 6e143293e17a ("HID: apple: Report Magic Keyboard battery over USB")
>> Cc: stable@...r.kernel.org
>> Signed-off-by: Aditya Garg <gargaditya08@...e.com>
>> ---
>>  drivers/hid/hid-apple.c | 13 ++++++++-----
>>  1 file changed, 8 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
>> index b8b99eb01..b9f45c089 100644
>> --- a/drivers/hid/hid-apple.c
>> +++ b/drivers/hid/hid-apple.c
>> @@ -959,10 +959,12 @@ static int apple_probe(struct hid_device *hdev,
>>  		return ret;
>>  	}
>>  
>> -	timer_setup(&asc->battery_timer, apple_battery_timer_tick, 0);
>> -	mod_timer(&asc->battery_timer,
>> -		  jiffies + msecs_to_jiffies(APPLE_BATTERY_TIMEOUT_MS));
>> -	apple_fetch_battery(hdev);
>> +	if (quirks & APPLE_RDESC_BATTERY) {
>> +		timer_setup(&asc->battery_timer, apple_battery_timer_tick, 0);
>> +		mod_timer(&asc->battery_timer,
>> +			  jiffies + msecs_to_jiffies(APPLE_BATTERY_TIMEOUT_MS));
>> +		apple_fetch_battery(hdev);
>> +	}
>>
> 
> The same here, the `out_err:` error case uses the timer and it can
> be uninitialized.

Ah yes, good catch

> 
> Jose
> 
>>  	if (quirks & APPLE_BACKLIGHT_CTL)
>>  		apple_backlight_init(hdev);
>> @@ -985,7 +987,8 @@ static void apple_remove(struct hid_device *hdev)
>>  {
>>  	struct apple_sc *asc = hid_get_drvdata(hdev);
>>  
>> -	timer_delete_sync(&asc->battery_timer);
>> +	if (asc->quirks & APPLE_RDESC_BATTERY)
>> +		timer_delete_sync(&asc->battery_timer);
>>  
>>  	hid_hw_stop(hdev);
>>  }
>> -- 
>> 2.43.0
>>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ