SWDEV-342013,SWDEV-342014 - Update validation on hipDeviceGet and hipDeviceGetName

Change-Id: I719da6169ce9f505449e07775cb94a5718f79ca3
このコミットが含まれているのは:
Julia Jiang
2022-06-23 15:33:22 -04:00
committed by Julia Jiang
コミット 3415f0a56e
+7 -2
ファイルの表示
@@ -121,9 +121,14 @@ void ihipDestroyDevice() {
}
hipError_t ihipDeviceGet(hipDevice_t* device, int deviceId) {
if (deviceId < 0 || static_cast<size_t>(deviceId) >= g_devices.size() || device == nullptr) {
if (device == nullptr) {
return hipErrorInvalidValue;
}
if (deviceId < 0 || static_cast<size_t>(deviceId) >= g_devices.size()) {
return hipErrorInvalidDevice;
}
*device = deviceId;
return hipSuccess;
}
@@ -213,7 +218,7 @@ hipError_t hipDeviceGetName(char *name, int len, hipDevice_t device) {
// Make sure that the size of `dest` is big enough to hold `src` including
// trailing zero byte
if (nameLen > (cl_uint)(len - 1)) {
if (nameLen <= 0) {
HIP_RETURN(hipErrorInvalidValue);
}