All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ACPI / PNP: check the string length of pnp device id in matching_id
@ 2020-12-10  1:25 Hui Wang
  2020-12-10  9:04 ` Greg KH
  2020-12-10 13:57 ` Rafael J. Wysocki
  0 siblings, 2 replies; 6+ messages in thread
From: Hui Wang @ 2020-12-10  1:25 UTC (permalink / raw)
  To: linux-acpi, rafael.j.wysocki; +Cc: lenb, stable

Recently we met a touchscreen problem on some Thinkpad machines, the
touchscreen driver (i2c-hid) is not loaded and the touchscreen can't
work.

An i2c ACPI device with the name WACF2200 is defined in the BIOS, with
the current ACPI PNP matching rule, this device will be regarded as
a PNP device since there is WACFXXX in the acpi_pnp_device_ids[] and
this PNP device is attached to the acpi device as the 1st
physical_node, this will make the i2c bus match fail when i2c bus
calls acpi_companion_match() to match the acpi_id_table in the i2c-hid
driver.

An ACPI PNP device's id has fixed format and its string length equals
7, after adding this check in the matching_id, the touchscreen could
work.

Cc: stable@vger.kernel.org
Signed-off-by: Hui Wang <hui.wang@canonical.com>
---
 drivers/acpi/acpi_pnp.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c
index 4ed755a963aa..5ce711b9b070 100644
--- a/drivers/acpi/acpi_pnp.c
+++ b/drivers/acpi/acpi_pnp.c
@@ -319,6 +319,10 @@ static bool matching_id(const char *idstr, const char *list_id)
 {
 	int i;
 
+	/* a pnp device id has CCCdddd format (C character, d digit), strlen should be 7 */
+	if (strlen(idstr) != 7)
+		return false;
+
 	if (memcmp(idstr, list_id, 3))
 		return false;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] ACPI / PNP: check the string length of pnp device id in matching_id
  2020-12-10  1:25 [PATCH v2] ACPI / PNP: check the string length of pnp device id in matching_id Hui Wang
@ 2020-12-10  9:04 ` Greg KH
  2020-12-11  0:41   ` Hui Wang
  2020-12-10 13:57 ` Rafael J. Wysocki
  1 sibling, 1 reply; 6+ messages in thread
From: Greg KH @ 2020-12-10  9:04 UTC (permalink / raw)
  To: Hui Wang; +Cc: linux-acpi, rafael.j.wysocki, lenb, stable

On Thu, Dec 10, 2020 at 09:25:39AM +0800, Hui Wang wrote:
> Recently we met a touchscreen problem on some Thinkpad machines, the
> touchscreen driver (i2c-hid) is not loaded and the touchscreen can't
> work.
> 
> An i2c ACPI device with the name WACF2200 is defined in the BIOS, with
> the current ACPI PNP matching rule, this device will be regarded as
> a PNP device since there is WACFXXX in the acpi_pnp_device_ids[] and
> this PNP device is attached to the acpi device as the 1st
> physical_node, this will make the i2c bus match fail when i2c bus
> calls acpi_companion_match() to match the acpi_id_table in the i2c-hid
> driver.
> 
> An ACPI PNP device's id has fixed format and its string length equals
> 7, after adding this check in the matching_id, the touchscreen could
> work.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Hui Wang <hui.wang@canonical.com>
> ---
>  drivers/acpi/acpi_pnp.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c
> index 4ed755a963aa..5ce711b9b070 100644
> --- a/drivers/acpi/acpi_pnp.c
> +++ b/drivers/acpi/acpi_pnp.c
> @@ -319,6 +319,10 @@ static bool matching_id(const char *idstr, const char *list_id)
>  {
>  	int i;
>  
> +	/* a pnp device id has CCCdddd format (C character, d digit), strlen should be 7 */
> +	if (strlen(idstr) != 7)
> +		return false;

Shouldn't you verify that the format is correct as well?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] ACPI / PNP: check the string length of pnp device id in matching_id
  2020-12-10  1:25 [PATCH v2] ACPI / PNP: check the string length of pnp device id in matching_id Hui Wang
  2020-12-10  9:04 ` Greg KH
@ 2020-12-10 13:57 ` Rafael J. Wysocki
  2020-12-11  0:43   ` Hui Wang
  1 sibling, 1 reply; 6+ messages in thread
From: Rafael J. Wysocki @ 2020-12-10 13:57 UTC (permalink / raw)
  To: Hui Wang; +Cc: ACPI Devel Maling List, Rafael Wysocki, Len Brown, Stable

On Thu, Dec 10, 2020 at 2:27 AM Hui Wang <hui.wang@canonical.com> wrote:
>
> Recently we met a touchscreen problem on some Thinkpad machines, the
> touchscreen driver (i2c-hid) is not loaded and the touchscreen can't
> work.
>
> An i2c ACPI device with the name WACF2200 is defined in the BIOS, with
> the current ACPI PNP matching rule, this device will be regarded as
> a PNP device since there is WACFXXX in the acpi_pnp_device_ids[] and
> this PNP device is attached to the acpi device as the 1st
> physical_node, this will make the i2c bus match fail when i2c bus
> calls acpi_companion_match() to match the acpi_id_table in the i2c-hid
> driver.
>
> An ACPI PNP device's id has fixed format and its string length equals
> 7, after adding this check in the matching_id, the touchscreen could
> work.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Hui Wang <hui.wang@canonical.com>
> ---
>  drivers/acpi/acpi_pnp.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c
> index 4ed755a963aa..5ce711b9b070 100644
> --- a/drivers/acpi/acpi_pnp.c
> +++ b/drivers/acpi/acpi_pnp.c
> @@ -319,6 +319,10 @@ static bool matching_id(const char *idstr, const char *list_id)
>  {
>         int i;
>
> +       /* a pnp device id has CCCdddd format (C character, d digit), strlen should be 7 */
> +       if (strlen(idstr) != 7)
> +               return false;

What I meant was comparing the length of the arg strings and return
false if they don't match.  Wouldn't that work?

> +
>         if (memcmp(idstr, list_id, 3))
>                 return false;
>
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] ACPI / PNP: check the string length of pnp device id in matching_id
  2020-12-10  9:04 ` Greg KH
@ 2020-12-11  0:41   ` Hui Wang
  2020-12-11 17:07     ` Rafael J. Wysocki
  0 siblings, 1 reply; 6+ messages in thread
From: Hui Wang @ 2020-12-11  0:41 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-acpi, rafael.j.wysocki, lenb, stable


On 12/10/20 5:04 PM, Greg KH wrote:
> On Thu, Dec 10, 2020 at 09:25:39AM +0800, Hui Wang wrote:
>> Recently we met a touchscreen problem on some Thinkpad machines, the
>> touchscreen driver (i2c-hid) is not loaded and the touchscreen can't
>> work.
>>
>> An i2c ACPI device with the name WACF2200 is defined in the BIOS, with
>> the current ACPI PNP matching rule, this device will be regarded as
>> a PNP device since there is WACFXXX in the acpi_pnp_device_ids[] and
>> this PNP device is attached to the acpi device as the 1st
>> physical_node, this will make the i2c bus match fail when i2c bus
>> calls acpi_companion_match() to match the acpi_id_table in the i2c-hid
>> driver.
>>
>> An ACPI PNP device's id has fixed format and its string length equals
>> 7, after adding this check in the matching_id, the touchscreen could
>> work.
>>
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Hui Wang <hui.wang@canonical.com>
>> ---
>>   drivers/acpi/acpi_pnp.c | 4 ++++
>>   1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c
>> index 4ed755a963aa..5ce711b9b070 100644
>> --- a/drivers/acpi/acpi_pnp.c
>> +++ b/drivers/acpi/acpi_pnp.c
>> @@ -319,6 +319,10 @@ static bool matching_id(const char *idstr, const char *list_id)
>>   {
>>   	int i;
>>   
>> +	/* a pnp device id has CCCdddd format (C character, d digit), strlen should be 7 */
>> +	if (strlen(idstr) != 7)
>> +		return false;
> Shouldn't you verify that the format is correct as well?

I thought the rest code in this function will verify the format, just 
missing the length checking. But I was wrong, "a pnp device id has 
CCCdddd format" is not correct since WACFXXX is a valid id, I will 
follow Rafael's advice:  compare two string's length.

Thanks.


>
> thanks,
>
> greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] ACPI / PNP: check the string length of pnp device id in matching_id
  2020-12-10 13:57 ` Rafael J. Wysocki
@ 2020-12-11  0:43   ` Hui Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Hui Wang @ 2020-12-11  0:43 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: ACPI Devel Maling List, Rafael Wysocki, Len Brown, Stable


On 12/10/20 9:57 PM, Rafael J. Wysocki wrote:
> On Thu, Dec 10, 2020 at 2:27 AM Hui Wang <hui.wang@canonical.com> wrote:
>> Recently we met a touchscreen problem on some Thinkpad machines, the
>> touchscreen driver (i2c-hid) is not loaded and the touchscreen can't
>> work.
>>
>> An i2c ACPI device with the name WACF2200 is defined in the BIOS, with
>> the current ACPI PNP matching rule, this device will be regarded as
>> a PNP device since there is WACFXXX in the acpi_pnp_device_ids[] and
>> this PNP device is attached to the acpi device as the 1st
>> physical_node, this will make the i2c bus match fail when i2c bus
>> calls acpi_companion_match() to match the acpi_id_table in the i2c-hid
>> driver.
>>
>> An ACPI PNP device's id has fixed format and its string length equals
>> 7, after adding this check in the matching_id, the touchscreen could
>> work.
>>
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Hui Wang <hui.wang@canonical.com>
>> ---
>>   drivers/acpi/acpi_pnp.c | 4 ++++
>>   1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c
>> index 4ed755a963aa..5ce711b9b070 100644
>> --- a/drivers/acpi/acpi_pnp.c
>> +++ b/drivers/acpi/acpi_pnp.c
>> @@ -319,6 +319,10 @@ static bool matching_id(const char *idstr, const char *list_id)
>>   {
>>          int i;
>>
>> +       /* a pnp device id has CCCdddd format (C character, d digit), strlen should be 7 */
>> +       if (strlen(idstr) != 7)
>> +               return false;
> What I meant was comparing the length of the arg strings and return
> false if they don't match.  Wouldn't that work?

Oh, got it.

Thanks.

>
>> +
>>          if (memcmp(idstr, list_id, 3))
>>                  return false;
>>
>> --
>> 2.25.1
>>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] ACPI / PNP: check the string length of pnp device id in matching_id
  2020-12-11  0:41   ` Hui Wang
@ 2020-12-11 17:07     ` Rafael J. Wysocki
  0 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2020-12-11 17:07 UTC (permalink / raw)
  To: Hui Wang
  Cc: Greg KH, ACPI Devel Maling List, Rafael Wysocki, Len Brown, Stable

On Fri, Dec 11, 2020 at 1:43 AM Hui Wang <hui.wang@canonical.com> wrote:
>
> On 12/10/20 5:04 PM, Greg KH wrote:
> > On Thu, Dec 10, 2020 at 09:25:39AM +0800, Hui Wang wrote:
> >> Recently we met a touchscreen problem on some Thinkpad machines, the
> >> touchscreen driver (i2c-hid) is not loaded and the touchscreen can't
> >> work.
> >>
> >> An i2c ACPI device with the name WACF2200 is defined in the BIOS, with
> >> the current ACPI PNP matching rule, this device will be regarded as
> >> a PNP device since there is WACFXXX in the acpi_pnp_device_ids[] and
> >> this PNP device is attached to the acpi device as the 1st
> >> physical_node, this will make the i2c bus match fail when i2c bus
> >> calls acpi_companion_match() to match the acpi_id_table in the i2c-hid
> >> driver.
> >>
> >> An ACPI PNP device's id has fixed format and its string length equals
> >> 7, after adding this check in the matching_id, the touchscreen could
> >> work.
> >>
> >> Cc: stable@vger.kernel.org
> >> Signed-off-by: Hui Wang <hui.wang@canonical.com>
> >> ---
> >>   drivers/acpi/acpi_pnp.c | 4 ++++
> >>   1 file changed, 4 insertions(+)
> >>
> >> diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c
> >> index 4ed755a963aa..5ce711b9b070 100644
> >> --- a/drivers/acpi/acpi_pnp.c
> >> +++ b/drivers/acpi/acpi_pnp.c
> >> @@ -319,6 +319,10 @@ static bool matching_id(const char *idstr, const char *list_id)
> >>   {
> >>      int i;
> >>
> >> +    /* a pnp device id has CCCdddd format (C character, d digit), strlen should be 7 */
> >> +    if (strlen(idstr) != 7)
> >> +            return false;
> > Shouldn't you verify that the format is correct as well?
>
> I thought the rest code in this function will verify the format, just
> missing the length checking. But I was wrong, "a pnp device id has
> CCCdddd format" is not correct since WACFXXX is a valid id,

In fact, the "F" may be regarded as a hex digit and so this follows
the CCCdddd format too.

The problem with the current code is that it matches ACPI device IDs
in the WACFdddd format against the WACFXXX string, which is incorrect.

> I will follow Rafael's advice:  compare two string's length.

Please do.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-12-11 18:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-10  1:25 [PATCH v2] ACPI / PNP: check the string length of pnp device id in matching_id Hui Wang
2020-12-10  9:04 ` Greg KH
2020-12-11  0:41   ` Hui Wang
2020-12-11 17:07     ` Rafael J. Wysocki
2020-12-10 13:57 ` Rafael J. Wysocki
2020-12-11  0:43   ` Hui Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.