Skip to contentSkip to conversation

drm/amd/pm/swsmu: Avoid using structure_size uninitialized in smu_cmn_init_soft_gpu_metrics

PATCH Applied Nathan Chancellor 4 participants 4 messages Feb 18, 2021 – Feb 24, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/pm/swsmu: Avoid using structure_size uninitialized in smu_cmn_init_soft_gpu_metrics

Clang warns:

drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu_cmn.c:764:2: warning:
variable 'structure_size' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]

        default:
        ^~~~~~~
drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu_cmn.c:770:23: note:
uninitialized use occurs here
        memset(header, 0xFF, structure_size);
                             ^~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu_cmn.c:753:25: note:
initialize the variable 'structure_size' to silence this warning
        uint16_t structure_size;
                               ^
                                = 0

1 warning generated.

Return in the default case, as the size of the header will not be known.

Fixes de4b7cd8cb87 ("drm/amd/pm/swsmu: unify the init soft gpu metrics function")
---
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1 -1
index bb620fdd4cd2..bcedd4d92e35 100644
@@ -762,7 +762,7 @@ void smu_cmn_init_soft_gpu_metrics(void *table, uint8_t frev, uint8_t crev)
 		structure_size = sizeof(struct gpu_metrics_v2_0);
 		break;
 	default:
-		break;
+		return;
 	}
 
 #undef METRICS_VERSION
Signature · 6 lines
2.30.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by on v1 1/1
#1 lore raw

thanks,

Regards,
Kevin

Quoted 45 lines · 在 2021年2月19日,06:49,Nathan Chancellor <[email protected]> 写道:

Clang warns:

drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu_cmn.c:764:2: warning:
variable 'structure_size' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]

       default:
       ^~~~~~~
drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu_cmn.c:770:23: note:
uninitialized use occurs here
       memset(header, 0xFF, structure_size);
                            ^~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu_cmn.c:753:25: note:
initialize the variable 'structure_size' to silence this warning
       uint16_t structure_size;
                              ^
                               = 0

1 warning generated.

Return in the default case, as the size of the header will not be known.

Fixes de4b7cd8cb87 ("drm/amd/pm/swsmu: unify the init soft gpu metrics function")

---
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1 -1
index bb620fdd4cd2..bcedd4d92e35 100644
@@ -762,7 +762,7 @@ void smu_cmn_init_soft_gpu_metrics(void *table, uint8_t frev, uint8_t crev)
       structure_size = sizeof(struct gpu_metrics_v2_0);
       break;
   default:
-        break;
+        return;
   }
 
 #undef METRICS_VERSION
Signature · 1 line
2.30.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Applied
#2 lore raw

Applied. Thanks!

Alex

Quoted 49 lines · Kevin(Yang)

thanks,

Regards,
Kevin

Quoted 41 lines · 在 2021年2月19日,06:49,Nathan Chancellor <[email protected]> 写道:

Clang warns:

drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu_cmn.c:764:2: warning:
variable 'structure_size' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]

       default:
       ^~~~~~~
drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu_cmn.c:770:23: note:
uninitialized use occurs here
       memset(header, 0xFF, structure_size);
                            ^~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu_cmn.c:753:25: note:
initialize the variable 'structure_size' to silence this warning
       uint16_t structure_size;
                              ^
                               = 0

1 warning generated.

Return in the default case, as the size of the header will not be known.

Fixes de4b7cd8cb87 ("drm/amd/pm/swsmu: unify the init soft gpu metrics function")

---
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1 -1
index bb620fdd4cd2..bcedd4d92e35 100644
@@ -762,7 +762,7 @@ void smu_cmn_init_soft_gpu_metrics(void *table, uint8_t frev, uint8_t crev)
       structure_size = sizeof(struct gpu_metrics_v2_0);
       break;
   default:
-        break;
+        return;
   }
 
Quoted 8 lines
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0 -1
 #undef METRICS_VERSION
--

2.30.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Tested-by on v1 1/1
#3 lore raw
In reply to Nathan Chancellor
Quoted 17 lines · Nathan Chancellor

Clang warns:

drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu_cmn.c:764:2: warning:
variable 'structure_size' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]

        default:
        ^~~~~~~
drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu_cmn.c:770:23: note:
uninitialized use occurs here
        memset(header, 0xFF, structure_size);
                             ^~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu_cmn.c:753:25: note:
initialize the variable 'structure_size' to silence this warning
        uint16_t structure_size;
                               ^
                                = 0
Quoted 7 lines

1 warning generated.

Return in the default case, as the size of the header will not be known.

Fixes de4b7cd8cb87 ("drm/amd/pm/swsmu: unify the init soft gpu metrics function")

I fell over this today with Linux v5.11-10201-gc03c21ba6f4e.

- Sedat -

Quoted 24 lines
---
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1 -2
index bb620fdd4cd2..bcedd4d92e35 100644
@@ -762,7 +762,7 @@ void smu_cmn_init_soft_gpu_metrics(void *table, uint8_t frev, uint8_t crev)
                structure_size = sizeof(struct gpu_metrics_v2_0);
                break;
        default:
-               break;
+               return;
        }
 
 #undef METRICS_VERSION
--

2.30.1

--
You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20210218224849.5591-1-nathan%40kernel.org.