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]
Date:   Tue, 13 Dec 2022 14:53:45 +0100 (CET)
From:   Sven Zühlsdorf <sven.zuehlsdorf@...em.de>
To:     Bjorn Helgaas <helgaas@...nel.org>
cc:     Lars Povlsen <lars.povlsen@...rochip.com>,
        Rishi Gupta <gupt21@...il.com>, Jiri Kosina <jikos@...nel.org>,
        Benjamin Tissoires <benjamin.tissoires@...hat.com>,
        UNGLinuxDriver <UNGLinuxDriver@...rochip.com>,
        linux-i2c@...r.kernel.org, linux-input@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        Takayuki 'January June' Suwa <jjsuwa_sys3175@...oo.co.jp>
Subject: Re: [PATCH] HID: mcp2221: Fix GPIO output handling

On Tue, 29 Nov 2022, Bjorn Helgaas wrote:
> [+cc Takayuki, thanks for your report!]
>
> On Wed, Nov 04, 2020 at 11:02:23PM +0100, Lars Povlsen wrote:
>> The mcp2221 driver GPIO output handling has has several issues.
>>
>> * A wrong value is used for the GPIO direction.
>>
>> * Wrong offsets are calculated for some GPIO set value/set direction
>>   operations, when offset is larger than 0.
>>
>> This has been fixed by introducing proper manifest constants for the
>> direction encoding, and using 'offsetof' when calculating GPIO
>> register offsets.
>>
>> The updated driver has been tested with the Sparx5 pcb134/pcb135
>> board, which has the mcp2221 device with several (output) GPIO's.
>>
>> Signed-off-by: Lars Povlsen <lars.povlsen@...rochip.com>
>> ---
>>  drivers/hid/hid-mcp2221.c | 48 +++++++++++++++++++++++++++++++--------
>>  1 file changed, 39 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c
>> index 0d27ccb55dd9..4211b9839209 100644
>> --- a/drivers/hid/hid-mcp2221.c
>> +++ b/drivers/hid/hid-mcp2221.c
>
>> +/* MCP GPIO get command layout */
>> +struct mcp_get_gpio {
>> +	u8 cmd;
>> +	u8 dummy;
>> +	struct {
>> +		u8 direction;
>> +		u8 value;
>> +	} gpio[MCP_NGPIO];
>> +} __packed;
>
> This bug report: https://bugzilla.kernel.org/show_bug.cgi?id=216736
> suggests that direction and value may be reversed here.
>
> Mentioning here in case nobody actively monitors the bugzilla.
>
> Bjorn
>

I can confirm that the order is reversed when compared to both the data sheet
and what I can observe in the hid reports.
The patch from the linked bugzilla bug fixes the issue for me.

> --- a/drivers/hid/hid-mcp2221.c
> +++ b/drivers/hid/hid-mcp2221.c
> @@ -74,8 +74,8 @@ struct mcp_get_gpio {
>  	u8 cmd;
>  	u8 dummy;
>  	struct {
> -		u8 direction;
>  		u8 value;
> +		u8 direction;
>  	} gpio[MCP_NGPIO];
>  } __packed;

Tested-by: Sven Zühlsdorf <sven.zuehlsdorf@...em.de>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ