* [PATCH] hwmon: (hp-wmi-sensors) Initialize pevents in hp_wmi_sensors_init()
@ 2023-07-25 9:48 James Seo
2023-07-25 15:10 ` Guenter Roeck
2023-07-25 15:12 ` Guenter Roeck
0 siblings, 2 replies; 3+ messages in thread
From: James Seo @ 2023-07-25 9:48 UTC (permalink / raw)
To: Jean Delvare, Guenter Roeck
Cc: James Seo, Dan Carpenter, linux-hwmon, platform-driver-x86, linux-kernel
The following warning is given by the Smatch static checker:
drivers/hwmon/hp-wmi-sensors.c:1937 hp_wmi_sensors_init()
error: uninitialized symbol 'pevents'.
If there are no instances of the HPBIOS_PlatformEvents WMI object
available, init_platform_events() never initializes this pointer,
which may then be passed to hp_wmi_debugfs_init() uninitialized.
The impact should be limited because hp_wmi_debugfs_init() uses this
pointer only if the count of HPBIOS_PlatformEvents instances is _not_
zero, while conversely, it will be uninitialized only if the count of
such instances _is_ zero. However, passing it uninitialized still
constitutes a bug.
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-hwmon/f72c129b-8c57-406a-bf41-bd889b65ea0f@moroto.mountain/
Signed-off-by: James Seo <james@equiv.tech>
---
drivers/hwmon/hp-wmi-sensors.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hwmon/hp-wmi-sensors.c b/drivers/hwmon/hp-wmi-sensors.c
index 3a99cc5f44b2..17ae62f88bbf 100644
--- a/drivers/hwmon/hp-wmi-sensors.c
+++ b/drivers/hwmon/hp-wmi-sensors.c
@@ -1913,7 +1913,7 @@ static bool add_event_handler(struct hp_wmi_sensors *state)
static int hp_wmi_sensors_init(struct hp_wmi_sensors *state)
{
struct hp_wmi_info *connected[HP_WMI_MAX_INSTANCES];
- struct hp_wmi_platform_events *pevents;
+ struct hp_wmi_platform_events *pevents = NULL;
struct device *dev = &state->wdev->dev;
struct hp_wmi_info *info;
struct device *hwdev;
base-commit: 55612007f16b5d7b1fb83a7b0f5bb686829db7c7
--
2.39.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hwmon: (hp-wmi-sensors) Initialize pevents in hp_wmi_sensors_init()
2023-07-25 9:48 [PATCH] hwmon: (hp-wmi-sensors) Initialize pevents in hp_wmi_sensors_init() James Seo
@ 2023-07-25 15:10 ` Guenter Roeck
2023-07-25 15:12 ` Guenter Roeck
1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2023-07-25 15:10 UTC (permalink / raw)
To: James Seo
Cc: Jean Delvare, Dan Carpenter, linux-hwmon, platform-driver-x86,
linux-kernel
On Tue, Jul 25, 2023 at 02:48:17AM -0700, James Seo wrote:
> The following warning is given by the Smatch static checker:
>
> drivers/hwmon/hp-wmi-sensors.c:1937 hp_wmi_sensors_init()
> error: uninitialized symbol 'pevents'.
>
> If there are no instances of the HPBIOS_PlatformEvents WMI object
> available, init_platform_events() never initializes this pointer,
> which may then be passed to hp_wmi_debugfs_init() uninitialized.
>
> The impact should be limited because hp_wmi_debugfs_init() uses this
> pointer only if the count of HPBIOS_PlatformEvents instances is _not_
> zero, while conversely, it will be uninitialized only if the count of
> such instances _is_ zero. However, passing it uninitialized still
> constitutes a bug.
>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/linux-hwmon/f72c129b-8c57-406a-bf41-bd889b65ea0f@moroto.mountain/
> Signed-off-by: James Seo <james@equiv.tech>
Applied.
Thanks,
Guenter
> ---
> drivers/hwmon/hp-wmi-sensors.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>
> base-commit: 55612007f16b5d7b1fb83a7b0f5bb686829db7c7
>
> diff --git a/drivers/hwmon/hp-wmi-sensors.c b/drivers/hwmon/hp-wmi-sensors.c
> index 3a99cc5f44b2..17ae62f88bbf 100644
> --- a/drivers/hwmon/hp-wmi-sensors.c
> +++ b/drivers/hwmon/hp-wmi-sensors.c
> @@ -1913,7 +1913,7 @@ static bool add_event_handler(struct hp_wmi_sensors *state)
> static int hp_wmi_sensors_init(struct hp_wmi_sensors *state)
> {
> struct hp_wmi_info *connected[HP_WMI_MAX_INSTANCES];
> - struct hp_wmi_platform_events *pevents;
> + struct hp_wmi_platform_events *pevents = NULL;
> struct device *dev = &state->wdev->dev;
> struct hp_wmi_info *info;
> struct device *hwdev;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hwmon: (hp-wmi-sensors) Initialize pevents in hp_wmi_sensors_init()
2023-07-25 9:48 [PATCH] hwmon: (hp-wmi-sensors) Initialize pevents in hp_wmi_sensors_init() James Seo
2023-07-25 15:10 ` Guenter Roeck
@ 2023-07-25 15:12 ` Guenter Roeck
1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2023-07-25 15:12 UTC (permalink / raw)
To: James Seo
Cc: Jean Delvare, Dan Carpenter, linux-hwmon, platform-driver-x86,
linux-kernel
On Tue, Jul 25, 2023 at 02:48:17AM -0700, James Seo wrote:
> The following warning is given by the Smatch static checker:
>
> drivers/hwmon/hp-wmi-sensors.c:1937 hp_wmi_sensors_init()
> error: uninitialized symbol 'pevents'.
>
> If there are no instances of the HPBIOS_PlatformEvents WMI object
> available, init_platform_events() never initializes this pointer,
> which may then be passed to hp_wmi_debugfs_init() uninitialized.
>
> The impact should be limited because hp_wmi_debugfs_init() uses this
> pointer only if the count of HPBIOS_PlatformEvents instances is _not_
> zero, while conversely, it will be uninitialized only if the count of
> such instances _is_ zero. However, passing it uninitialized still
> constitutes a bug.
>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/linux-hwmon/f72c129b-8c57-406a-bf41-bd889b65ea0f@moroto.mountain/
> Signed-off-by: James Seo <james@equiv.tech>
Applied.
Thanks,
Guenter
> ---
> drivers/hwmon/hp-wmi-sensors.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>
> base-commit: 55612007f16b5d7b1fb83a7b0f5bb686829db7c7
>
> diff --git a/drivers/hwmon/hp-wmi-sensors.c b/drivers/hwmon/hp-wmi-sensors.c
> index 3a99cc5f44b2..17ae62f88bbf 100644
> --- a/drivers/hwmon/hp-wmi-sensors.c
> +++ b/drivers/hwmon/hp-wmi-sensors.c
> @@ -1913,7 +1913,7 @@ static bool add_event_handler(struct hp_wmi_sensors *state)
> static int hp_wmi_sensors_init(struct hp_wmi_sensors *state)
> {
> struct hp_wmi_info *connected[HP_WMI_MAX_INSTANCES];
> - struct hp_wmi_platform_events *pevents;
> + struct hp_wmi_platform_events *pevents = NULL;
> struct device *dev = &state->wdev->dev;
> struct hp_wmi_info *info;
> struct device *hwdev;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-07-25 15:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-25 9:48 [PATCH] hwmon: (hp-wmi-sensors) Initialize pevents in hp_wmi_sensors_init() James Seo
2023-07-25 15:10 ` Guenter Roeck
2023-07-25 15:12 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®