mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 13:28:06 +02:00
rusticl: Fix negative CTS device tests
`clRetainDevice` and `clReleaseDevice` ignore the device argument, it should be checked for validity and return `CL_INVALID_DEVICE` if it fails. `check_cl_device_type` fails if entrypoint is passed `0` as the device type. Zero as an input for a bitwise and operation will always result in a zero, so the utility function fails to return `CL_INVALID_DEVICE_TYPE`. Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37008>
This commit is contained in:
parent
c4e5661f29
commit
61fd24c552
2 changed files with 5 additions and 3 deletions
|
|
@ -393,12 +393,14 @@ fn get_device_ids(
|
|||
}
|
||||
|
||||
#[cl_entrypoint(clRetainDevice)]
|
||||
fn retain_device(_device: cl_device_id) -> CLResult<()> {
|
||||
fn retain_device(device: cl_device_id) -> CLResult<()> {
|
||||
let _ = Device::ref_from_raw(device)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cl_entrypoint(clReleaseDevice)]
|
||||
fn release_device(_device: cl_device_id) -> CLResult<()> {
|
||||
fn release_device(device: cl_device_id) -> CLResult<()> {
|
||||
let _ = Device::ref_from_raw(device)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -440,7 +440,7 @@ const CL_DEVICE_TYPES: u32 = CL_DEVICE_TYPE_ACCELERATOR
|
|||
|
||||
pub fn check_cl_device_type(val: cl_device_type) -> CLResult<()> {
|
||||
let v: u32 = val.try_into().or(Err(CL_INVALID_DEVICE_TYPE))?;
|
||||
if v == CL_DEVICE_TYPE_ALL || v & CL_DEVICE_TYPES == v {
|
||||
if v != 0 && (v == CL_DEVICE_TYPE_ALL || v & CL_DEVICE_TYPES == v) {
|
||||
return Ok(());
|
||||
}
|
||||
Err(CL_INVALID_DEVICE_TYPE)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue