gpu: nvgpu: check PMA stream reservation in get put API

Check if PMA stream resource is reserved in
nvgpu_prof_ioctl_pma_stream_update_get_put() before accessing PMA stream
data.

Bug 2510974
Jira NVGPU-5360

Change-Id: Id57cc74e1cd37a2eb12a36671011a18693af1219
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2418521
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Deepak Nibade
2020-09-23 17:49:48 +05:30
committed by Alex Waterman
parent dd9298c959
commit f9f82561cf

View File

@@ -665,6 +665,11 @@ static int nvgpu_prof_ioctl_pma_stream_update_get_put(struct nvgpu_profiler_obje
"Update PMA stream request %u: flags = 0x%x bytes_consumed=%llu", "Update PMA stream request %u: flags = 0x%x bytes_consumed=%llu",
prof->prof_handle, args->flags, args->bytes_consumed); prof->prof_handle, args->flags, args->bytes_consumed);
if (!prof->reserved[NVGPU_PROFILER_PM_RESOURCE_TYPE_PMA_STREAM]) {
nvgpu_err(g, "PMA stream resource not reserved");
return -EINVAL;
}
err = nvgpu_perfbuf_update_get_put(prof->g, args->bytes_consumed, err = nvgpu_perfbuf_update_get_put(prof->g, args->bytes_consumed,
update_bytes_available ? &args->bytes_available : NULL, update_bytes_available ? &args->bytes_available : NULL,
prof->pma_bytes_available_buffer_cpuva, wait, prof->pma_bytes_available_buffer_cpuva, wait,