drm/amd/display: Fix Coverity INTERGER_OVERFLOW within construct_integrated_info
authorjsg <jsg@openbsd.org>
Mon, 9 Sep 2024 08:54:26 +0000 (08:54 +0000)
committerjsg <jsg@openbsd.org>
Mon, 9 Sep 2024 08:54:26 +0000 (08:54 +0000)
From Hersen Wu
13faa9d401a5aa7a3b5211adb8ba0e9dddecaabb in linux-6.6.y/6.6.50
176abbcc71952e23009a6ed194fd203b99646884 in mainline linux

sys/dev/pci/drm/amd/display/dc/bios/bios_parser.c
sys/dev/pci/drm/amd/display/dc/bios/bios_parser2.c

index 6b31904..19cd1bd 100644 (file)
@@ -2552,8 +2552,8 @@ static enum bp_result construct_integrated_info(
 
        /* Sort voltage table from low to high*/
        if (result == BP_RESULT_OK) {
-               uint32_t i;
-               uint32_t j;
+               int32_t i;
+               int32_t j;
 
                for (i = 1; i < NUMBER_OF_DISP_CLK_VOLTAGE; ++i) {
                        for (j = i; j > 0; --j) {
index 93720cf..384ddb2 100644 (file)
@@ -2935,8 +2935,11 @@ static enum bp_result construct_integrated_info(
        struct atom_common_table_header *header;
        struct atom_data_revision revision;
 
-       uint32_t i;
-       uint32_t j;
+       int32_t i;
+       int32_t j;
+
+       if (!info)
+               return result;
 
        if (info && DATA_TABLES(integratedsysteminfo)) {
                header = GET_IMAGE(struct atom_common_table_header,