P4 to Git Change 1760530 by todli@todli-win-opencl-kv1 on 2019/03/22 17:00:25

SWDEV-182808 - Prevent ICD from loading outdated amdocl binary
	1. Keep track of library name in KHRicdVendorRec
	2. Check if library with the same name has already been loaded before adding it in ICD list

	http://ocltc.amd.com/reviews/r/16989/

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/icd/icd.c#12 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/icd/icd.h#11 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/icd/icd_linux.c#11 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/icd/icd_windows.c#11 edit


[ROCm/clr commit: be5b5d86c3]
Bu işleme şunda yer alıyor:
foreman
2019-03-22 18:24:01 -04:00
ebeveyn 53fce508aa
işleme f99b6a99d9
4 değiştirilmiş dosya ile 42 ekleme ve 1 silme
+18
Dosyayı Görüntüle
@@ -75,6 +75,17 @@ void khrIcdVendorAdd(const char *libraryName)
goto Done;
}
// get the library's file name
const char *libName = libraryName;
const char *c;
for (c = libraryName; *c; ++c)
{
if ((*c == '\\') || (*c == '/'))
{
libName = c + 1;
}
}
// ensure that we haven't already loaded this vendor
for (vendorIterator = khrIcdVendors; vendorIterator; vendorIterator = vendorIterator->next)
{
@@ -83,6 +94,11 @@ void khrIcdVendorAdd(const char *libraryName)
KHR_ICD_TRACE("already loaded vendor %s, nothing to do here\n", libraryName);
goto Done;
}
if (!strcmp(vendorIterator->libName, libName))
{
KHR_ICD_TRACE("already loaded library %s, nothing to do here\n", libName);
goto Done;
}
}
// get the library's clGetExtensionFunctionAddress pointer
@@ -180,6 +196,8 @@ void khrIcdVendorAdd(const char *libraryName)
KHR_ICD_TRACE("failed get platform handle to library\n");
continue;
}
vendor->libName = (char *)malloc(strlen(libName) + 1);
strcpy(vendor->libName, libName);
vendor->clGetExtensionFunctionAddress = p_clGetExtensionFunctionAddress;
vendor->platform = platforms[i];
vendor->suffix = suffix;
+3
Dosyayı Görüntüle
@@ -88,6 +88,9 @@ struct KHRicdVendorRec
// the loaded library object (true type varies on Linux versus Windows)
void *library;
// the file name of the library
char *libName;
// the extension suffix for this platform
char *suffix;
+10
Dosyayı Görüntüle
@@ -160,6 +160,16 @@ Cleanup:
{
closedir(dir);
}
KHRicdVendor *vendorIterator;
for (vendorIterator = khrIcdVendors; vendorIterator; vendorIterator = vendorIterator->next)
{
if (vendorIterator->libName != NULL)
{
free(vendorIterator->libName);
vendorIterator->libName = NULL;
}
}
}
// go through the list of vendors only once
+11 -1
Dosyayı Görüntüle
@@ -130,7 +130,17 @@ BOOL CALLBACK khrIcdOsVendorsEnumerate(PINIT_ONCE InitOnce, PVOID Parameter, PVO
{
KHR_ICD_TRACE("Failed to close platforms key %s, ignoring\n", platformsName);
}
KHRicdVendor *vendorIterator;
for (vendorIterator = khrIcdVendors; vendorIterator; vendorIterator = vendorIterator->next)
{
if (vendorIterator->libName != NULL)
{
free(vendorIterator->libName);
vendorIterator->libName = NULL;
}
}
return TRUE;
}