habanalabs: make sure cs type is valid in cs_ioctl_signal_wait
authorOded Gabbay <ogabbay@kernel.org>
Mon, 19 Oct 2020 06:06:18 +0000 (09:06 +0300)
committerOded Gabbay <ogabbay@kernel.org>
Mon, 30 Nov 2020 08:47:30 +0000 (10:47 +0200)
Although we get a valid cs type from the callee, in case new values
will be added in the future, it is best to check the expected values
in that function.

Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
drivers/misc/habanalabs/common/command_submission.c

index 5ece525..8da0526 100644 (file)
@@ -1068,9 +1068,11 @@ static int cs_ioctl_signal_wait(struct hl_fpriv *hpriv, enum hl_cs_type cs_type,
        if (cs_type == CS_TYPE_WAIT || cs_type == CS_TYPE_SIGNAL)
                rc = cs_ioctl_signal_wait_create_jobs(hdev, ctx, cs, q_type,
                                q_idx);
-       else
+       else if (cs_type == CS_TYPE_COLLECTIVE_WAIT)
                rc = hdev->asic_funcs->collective_wait_create_jobs(hdev, ctx,
                                cs, q_idx, collective_engine_id);
+       else
+               rc = -EINVAL;
 
        if (rc)
                goto free_cs_object;