OSDN Git Service

amdgpu: Fix a structure initialization issue
authorPan, Xinhui <Xinhui.Pan@amd.com>
Fri, 12 Apr 2019 05:42:01 +0000 (05:42 +0000)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 12 Apr 2019 16:38:41 +0000 (11:38 -0500)
struct drmPciBusInfo has been aligned to 6 bytes. So memcmp will access
the last byte which is not initialized.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: xinhui pan <xinhui.pan@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
tests/amdgpu/ras_tests.c

index 612ad1d..81c34ad 100644 (file)
@@ -196,6 +196,7 @@ static int amdgpu_ras_lookup_id(drmDevicePtr device)
 
        for (i = 0; i < MAX_CARDS_SUPPORTED; i++) {
                memset(str, 0, sizeof(str));
+               memset(&info, 0, sizeof(info));
                sprintf(path, "/sys/kernel/debug/dri/%d/name", i);
                if (get_file_contents(path, str, sizeof(str)) <= 0)
                        continue;