diff mbox series

[2/5] hwmon: (hp-wmi-sensors) Check if WMI event data exists

Message ID 20240822173810.11090-3-W_Armin@gmx.de (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series platform/x86: wmi: Pass event data directly to legacy notify handlers | expand

Commit Message

Armin Wolf Aug. 22, 2024, 5:38 p.m. UTC
The BIOS can choose to return no event data in response to a
WMI event, so the ACPI object passed to the WMI notify handler
can be NULL.

Check for such a situation and ignore the event in such a case.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 drivers/hwmon/hp-wmi-sensors.c | 3 +++
 1 file changed, 3 insertions(+)

--
2.39.2

Comments

James Seo Aug. 23, 2024, 5:57 a.m. UTC | #1
On Thu, Aug 22, 2024 at 07:38:07PM +0200, Armin Wolf wrote:
> The BIOS can choose to return no event data in response to a
> WMI event, so the ACPI object passed to the WMI notify handler
> can be NULL.
> 
> Check for such a situation and ignore the event in such a case.
> 
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> ---
>  drivers/hwmon/hp-wmi-sensors.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/hwmon/hp-wmi-sensors.c b/drivers/hwmon/hp-wmi-sensors.c
> index 6892518d537c..d6bdad26feb1 100644
> --- a/drivers/hwmon/hp-wmi-sensors.c
> +++ b/drivers/hwmon/hp-wmi-sensors.c
> @@ -1628,6 +1628,9 @@ static void hp_wmi_notify(union acpi_object *wobj, void *context)
>  	 * HPBIOS_BIOSEvent instance.
>  	 */
> 
> +	if (!wobj)
> +		return;
> +
>  	mutex_lock(&state->lock);
> 
>  	err = populate_event_from_wobj(dev, &event, wobj);
> --
> 2.39.2
> 

Reviewed-by: James Seo <james@equiv.tech>

That also goes for the portion of the previous patch in
this series dealing exclusively with hp-wmi-sensors.
Guenter Roeck Aug. 23, 2024, 6:03 a.m. UTC | #2
On Thu, Aug 22, 2024 at 07:38:07PM +0200, Armin Wolf wrote:
> The BIOS can choose to return no event data in response to a
> WMI event, so the ACPI object passed to the WMI notify handler
> can be NULL.
> 
> Check for such a situation and ignore the event in such a case.
> 
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>

Acked-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/hwmon/hp-wmi-sensors.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/hwmon/hp-wmi-sensors.c b/drivers/hwmon/hp-wmi-sensors.c
> index 6892518d537c..d6bdad26feb1 100644
> --- a/drivers/hwmon/hp-wmi-sensors.c
> +++ b/drivers/hwmon/hp-wmi-sensors.c
> @@ -1628,6 +1628,9 @@ static void hp_wmi_notify(union acpi_object *wobj, void *context)
>  	 * HPBIOS_BIOSEvent instance.
>  	 */
> 
> +	if (!wobj)
> +		return;
> +
>  	mutex_lock(&state->lock);
> 
>  	err = populate_event_from_wobj(dev, &event, wobj);
> --
> 2.39.2
> 
>
Ilpo Järvinen Aug. 27, 2024, 8:20 a.m. UTC | #3
On Thu, 22 Aug 2024, Armin Wolf wrote:

> The BIOS can choose to return no event data in response to a
> WMI event, so the ACPI object passed to the WMI notify handler
> can be NULL.
> 
> Check for such a situation and ignore the event in such a case.
> 
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> ---
>  drivers/hwmon/hp-wmi-sensors.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/hwmon/hp-wmi-sensors.c b/drivers/hwmon/hp-wmi-sensors.c
> index 6892518d537c..d6bdad26feb1 100644
> --- a/drivers/hwmon/hp-wmi-sensors.c
> +++ b/drivers/hwmon/hp-wmi-sensors.c
> @@ -1628,6 +1628,9 @@ static void hp_wmi_notify(union acpi_object *wobj, void *context)
>  	 * HPBIOS_BIOSEvent instance.
>  	 */
> 
> +	if (!wobj)
> +		return;
> +

I'm left to wonder why is this patch is not placed first? Can't this 
happen regardless who gets the wobj? And in that case, should this have
a Fixes tag?
Armin Wolf Aug. 27, 2024, 10:11 p.m. UTC | #4
Am 27.08.24 um 10:20 schrieb Ilpo Järvinen:

> On Thu, 22 Aug 2024, Armin Wolf wrote:
>
>> The BIOS can choose to return no event data in response to a
>> WMI event, so the ACPI object passed to the WMI notify handler
>> can be NULL.
>>
>> Check for such a situation and ignore the event in such a case.
>>
>> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
>> ---
>>   drivers/hwmon/hp-wmi-sensors.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/hwmon/hp-wmi-sensors.c b/drivers/hwmon/hp-wmi-sensors.c
>> index 6892518d537c..d6bdad26feb1 100644
>> --- a/drivers/hwmon/hp-wmi-sensors.c
>> +++ b/drivers/hwmon/hp-wmi-sensors.c
>> @@ -1628,6 +1628,9 @@ static void hp_wmi_notify(union acpi_object *wobj, void *context)
>>   	 * HPBIOS_BIOSEvent instance.
>>   	 */
>>
>> +	if (!wobj)
>> +		return;
>> +
> I'm left to wonder why is this patch is not placed first? Can't this
> happen regardless who gets the wobj? And in that case, should this have
> a Fixes tag?
>
Good point, i will send a v2 series to correct this.

Thanks,
Armin Wolf
diff mbox series

Patch

diff --git a/drivers/hwmon/hp-wmi-sensors.c b/drivers/hwmon/hp-wmi-sensors.c
index 6892518d537c..d6bdad26feb1 100644
--- a/drivers/hwmon/hp-wmi-sensors.c
+++ b/drivers/hwmon/hp-wmi-sensors.c
@@ -1628,6 +1628,9 @@  static void hp_wmi_notify(union acpi_object *wobj, void *context)
 	 * HPBIOS_BIOSEvent instance.
 	 */

+	if (!wobj)
+		return;
+
 	mutex_lock(&state->lock);

 	err = populate_event_from_wobj(dev, &event, wobj);