gpu: nvgpu: vm: plausibility check for nvgpu_vm_bind_channel

Ensure that the channel pointer passed to nvgpu_vm_bind_channel
is not NULL.
Update unit test accordingly.

JIRA NVGPU-4947.

Change-Id: I3f987ee9042066df83cc6101b20b4add3661fae8
Signed-off-by: Nicolas Benech <nbenech@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2291034
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Nicolas Benech
2020-02-06 11:19:08 -05:00
committed by Alex Waterman
parent 16b80d2c5c
commit e8c02f121b
3 changed files with 17 additions and 1 deletions

View File

@@ -821,6 +821,15 @@ int test_vm_bind(struct unit_module *m, struct gk20a *g, void *__args)
vm = create_test_vm(m, g);
/* Error testing */
g->ops.mm.vm_bind_channel(vm, NULL);
if (channel->vm == vm) {
ret = UNIT_FAIL;
unit_err(m, "nvgpu_vm_bind_channel did not fail as expected.\n");
goto exit;
}
/* Succesfull call */
g->ops.mm.vm_bind_channel(vm, channel);
if (channel->vm != vm) {
@@ -831,6 +840,7 @@ int test_vm_bind(struct unit_module *m, struct gk20a *g, void *__args)
ret = UNIT_SUCCESS;
exit:
g->fifo.channel = NULL;
free(channel);
nvgpu_vm_put(vm);
return ret;