diff --git a/src/hip_device.cpp b/src/hip_device.cpp index 5bf7c5bf4e..51fd5e4f81 100644 --- a/src/hip_device.cpp +++ b/src/hip_device.cpp @@ -174,7 +174,9 @@ hipError_t hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device) hipError_t e = hipSuccess; - if(pi != nullptr) { + if(pi == nullptr) { + return ihipLogStatus(hipErrorInvalidValue); + } auto * hipDevice = ihipGetDevice(device); hipDeviceProp_t *prop = &hipDevice->_props; @@ -236,9 +238,6 @@ hipError_t hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device) } else { e = hipErrorInvalidDevice; } - }else{ - e = hipErrorInvalidDevice; - } return ihipLogStatus(e); }