SWDEV-339551 - 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
CL#1760530
Change-Id: I1e0356422c71963788b76019b0d8db5b8542f9ee
[ROCm/clr commit: ed40c24fa3]
This commit is contained in:
@@ -57,6 +57,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)
|
||||
{
|
||||
@@ -65,6 +76,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
|
||||
@@ -162,6 +178,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;
|
||||
|
||||
@@ -67,6 +67,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;
|
||||
|
||||
|
||||
@@ -135,6 +135,16 @@ void khrIcdOsVendorsEnumerate(void)
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
|
||||
KHRicdVendor *vendorIterator;
|
||||
for (vendorIterator = khrIcdVendors; vendorIterator; vendorIterator = vendorIterator->next)
|
||||
{
|
||||
if (vendorIterator->libName != NULL)
|
||||
{
|
||||
free(vendorIterator->libName);
|
||||
vendorIterator->libName = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL != envPath)
|
||||
|
||||
@@ -235,6 +235,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 status;
|
||||
}
|
||||
|
||||
|
||||
مرجع در شماره جدید
Block a user