diff mbox series

[3/6] HID: asus: Add hid_is_using_ll_driver(usb_hid_driver) check

Message ID 20200428142254.252063-3-hdegoede@redhat.com (mailing list archive)
State Mainlined
Commit 4bc43a421218b6cebc7c926fea001b166ea3677c
Delegated to: Jiri Kosina
Headers show
Series [1/6] HID: asus: Only set EV_REP if we are adding a mapping | expand

Commit Message

Hans de Goede April 28, 2020, 2:22 p.m. UTC
Add a hid_is_using_ll_driver(usb_hid_driver) check to ensure that the
parent device is an usb_interface, before casting the parent device
pointer to an usb_interface pointer with to_usb_interface().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/hid/hid-asus.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jiri Kosina May 5, 2020, 2:32 p.m. UTC | #1
On Tue, 28 Apr 2020, Hans de Goede wrote:

> Add a hid_is_using_ll_driver(usb_hid_driver) check to ensure that the
> parent device is an usb_interface, before casting the parent device
> pointer to an usb_interface pointer with to_usb_interface().
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/hid/hid-asus.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
> index b3292ff3f61a..719eff589f92 100644
> --- a/drivers/hid/hid-asus.c
> +++ b/drivers/hid/hid-asus.c
> @@ -842,7 +842,8 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
>  	if (drvdata->quirks & QUIRK_IS_MULTITOUCH)
>  		drvdata->tp = &asus_i2c_tp;
>  
> -	if (drvdata->quirks & QUIRK_T100_KEYBOARD) {
> +	if ((drvdata->quirks & QUIRK_T100_KEYBOARD) &&
> +	    hid_is_using_ll_driver(hdev, &usb_hid_driver)) {
>  		struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
>  

I am going to push the whole patchset to for-5.8/asus branch later today, 
but I guess this one should better be taken as 5.7 fix still, right?

Thanks,
Hans de Goede May 6, 2020, 8:41 a.m. UTC | #2
Hi,

On 5/5/20 4:32 PM, Jiri Kosina wrote:
> On Tue, 28 Apr 2020, Hans de Goede wrote:
> 
>> Add a hid_is_using_ll_driver(usb_hid_driver) check to ensure that the
>> parent device is an usb_interface, before casting the parent device
>> pointer to an usb_interface pointer with to_usb_interface().
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>>   drivers/hid/hid-asus.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
>> index b3292ff3f61a..719eff589f92 100644
>> --- a/drivers/hid/hid-asus.c
>> +++ b/drivers/hid/hid-asus.c
>> @@ -842,7 +842,8 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
>>   	if (drvdata->quirks & QUIRK_IS_MULTITOUCH)
>>   		drvdata->tp = &asus_i2c_tp;
>>   
>> -	if (drvdata->quirks & QUIRK_T100_KEYBOARD) {
>> +	if ((drvdata->quirks & QUIRK_T100_KEYBOARD) &&
>> +	    hid_is_using_ll_driver(hdev, &usb_hid_driver)) {
>>   		struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
>>   
> 
> I am going to push the whole patchset to for-5.8/asus branch later today,

Thanks.

> but I guess this one should better be taken as 5.7 fix still, right?

I know that Benjamin has been insisting on these extra checks, which
is why I added it. But in practice not having the check does not really
seem to be a big issue, so whether to add it to 5.7.x or not is your call.

Regards,

Hans
Jiri Kosina May 6, 2020, 9:42 a.m. UTC | #3
On Wed, 6 May 2020, Hans de Goede wrote:

> >> diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
> >> index b3292ff3f61a..719eff589f92 100644
> >> --- a/drivers/hid/hid-asus.c
> >> +++ b/drivers/hid/hid-asus.c
> >> @@ -842,7 +842,8 @@ static int asus_probe(struct hid_device *hdev, const
> >> struct hid_device_id *id)
> >>    if (drvdata->quirks & QUIRK_IS_MULTITOUCH)
> >>     drvdata->tp = &asus_i2c_tp;
> >>   -	if (drvdata->quirks & QUIRK_T100_KEYBOARD) {
> >> +	if ((drvdata->quirks & QUIRK_T100_KEYBOARD) &&
> >> +	    hid_is_using_ll_driver(hdev, &usb_hid_driver)) {
> >>     struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
> >>   
> > 
> > I am going to push the whole patchset to for-5.8/asus branch later today,
> 
> Thanks.

Now pushed out, thanks.

> > but I guess this one should better be taken as 5.7 fix still, right?
> 
> I know that Benjamin has been insisting on these extra checks, which
> is why I added it. But in practice not having the check does not really
> seem to be a big issue, so whether to add it to 5.7.x or not is your call.

So I guess some wild device fuzzer might in theory be able to confuse it, 
but I don't immediately see how. So let's queue this all for 5.8.
diff mbox series

Patch

diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index b3292ff3f61a..719eff589f92 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -842,7 +842,8 @@  static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
 	if (drvdata->quirks & QUIRK_IS_MULTITOUCH)
 		drvdata->tp = &asus_i2c_tp;
 
-	if (drvdata->quirks & QUIRK_T100_KEYBOARD) {
+	if ((drvdata->quirks & QUIRK_T100_KEYBOARD) &&
+	    hid_is_using_ll_driver(hdev, &usb_hid_driver)) {
 		struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
 
 		if (intf->altsetting->desc.bInterfaceNumber == T100_TPAD_INTF) {