* [PATCH v2] drm/i915/hwmon: Silence UBSAN uninitialized bool variable warning
@ 2023-05-12 20:37 Ashutosh Dixit
2023-05-15 9:57 ` Andi Shyti
0 siblings, 1 reply; 2+ messages in thread
From: Ashutosh Dixit @ 2023-05-12 20:37 UTC (permalink / raw)
To: intel-gfx; +Cc: Andi Shyti, dri-devel
Loading i915 on UBSAN enabled kernels (CONFIG_UBSAN/CONFIG_UBSAN_BOOL)
causes the following warning:
UBSAN: invalid-load in drivers/gpu/drm/i915/gt/uc/intel_uc.c:558:2
load of value 255 is not a valid value for type '_Bool'
Call Trace:
dump_stack_lvl+0x57/0x7d
ubsan_epilogue+0x5/0x40
__ubsan_handle_load_invalid_value.cold+0x43/0x48
__uc_init_hw+0x76a/0x903 [i915]
...
i915_driver_probe+0xfb1/0x1eb0 [i915]
i915_pci_probe+0xbe/0x2d0 [i915]
The warning happens because during probe i915_hwmon is still not available
which results in the output boolean variable *old remaining
uninitialized. Silence the warning by initializing the variable to an
arbitrary value.
v2: Move variable initialization to the declaration (Andi)
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
---
drivers/gpu/drm/i915/gt/uc/intel_uc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc.c b/drivers/gpu/drm/i915/gt/uc/intel_uc.c
index 1381943b8973d..c8b9cbb7ba3a9 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_uc.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_uc.c
@@ -465,7 +465,7 @@ static int __uc_init_hw(struct intel_uc *uc)
struct intel_guc *guc = &uc->guc;
struct intel_huc *huc = &uc->huc;
int ret, attempts;
- bool pl1en;
+ bool pl1en = false;
GEM_BUG_ON(!intel_uc_supports_guc(uc));
GEM_BUG_ON(!intel_uc_wants_guc(uc));
--
2.38.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] drm/i915/hwmon: Silence UBSAN uninitialized bool variable warning
2023-05-12 20:37 [PATCH v2] drm/i915/hwmon: Silence UBSAN uninitialized bool variable warning Ashutosh Dixit
@ 2023-05-15 9:57 ` Andi Shyti
0 siblings, 0 replies; 2+ messages in thread
From: Andi Shyti @ 2023-05-15 9:57 UTC (permalink / raw)
To: Ashutosh Dixit; +Cc: intel-gfx, dri-devel
Hi Ashutosh,
On Fri, May 12, 2023 at 01:37:35PM -0700, Ashutosh Dixit wrote:
> Loading i915 on UBSAN enabled kernels (CONFIG_UBSAN/CONFIG_UBSAN_BOOL)
> causes the following warning:
>
> UBSAN: invalid-load in drivers/gpu/drm/i915/gt/uc/intel_uc.c:558:2
> load of value 255 is not a valid value for type '_Bool'
> Call Trace:
> dump_stack_lvl+0x57/0x7d
> ubsan_epilogue+0x5/0x40
> __ubsan_handle_load_invalid_value.cold+0x43/0x48
> __uc_init_hw+0x76a/0x903 [i915]
> ...
> i915_driver_probe+0xfb1/0x1eb0 [i915]
> i915_pci_probe+0xbe/0x2d0 [i915]
>
> The warning happens because during probe i915_hwmon is still not available
> which results in the output boolean variable *old remaining
> uninitialized. Silence the warning by initializing the variable to an
> arbitrary value.
>
> v2: Move variable initialization to the declaration (Andi)
>
> Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
> Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
> Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
pushed in drm-intel-gt-next.
Thanks,
Andi
> ---
> drivers/gpu/drm/i915/gt/uc/intel_uc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc.c b/drivers/gpu/drm/i915/gt/uc/intel_uc.c
> index 1381943b8973d..c8b9cbb7ba3a9 100644
> --- a/drivers/gpu/drm/i915/gt/uc/intel_uc.c
> +++ b/drivers/gpu/drm/i915/gt/uc/intel_uc.c
> @@ -465,7 +465,7 @@ static int __uc_init_hw(struct intel_uc *uc)
> struct intel_guc *guc = &uc->guc;
> struct intel_huc *huc = &uc->huc;
> int ret, attempts;
> - bool pl1en;
> + bool pl1en = false;
>
> GEM_BUG_ON(!intel_uc_supports_guc(uc));
> GEM_BUG_ON(!intel_uc_wants_guc(uc));
> --
> 2.38.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-15 9:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-12 20:37 [PATCH v2] drm/i915/hwmon: Silence UBSAN uninitialized bool variable warning Ashutosh Dixit
2023-05-15 9:57 ` Andi Shyti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox