]> git.baikalelectronics.ru Git - kernel.git/commitdiff
habanalabs: fix NULL dereference on cs timeout
authorYuri Nudelman <ynudelman@habana.ai>
Tue, 14 Jun 2022 12:14:20 +0000 (15:14 +0300)
committerOded Gabbay <ogabbay@kernel.org>
Tue, 12 Jul 2022 06:09:23 +0000 (09:09 +0300)
Device descriptor is accessed before an assignment

Signed-off-by: Yuri Nudelman <ynudelman@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
drivers/misc/habanalabs/common/command_submission.c

index 72a557b83a7dd95e36d5d12fc49ab35829671743..c050f38b7091f833c392b1c4127ae208f9bb9663 100644 (file)
@@ -812,6 +812,8 @@ static void cs_timedout(struct work_struct *work)
                return;
        }
 
+       hdev = cs->ctx->hdev;
+
        if (likely(!skip_reset_on_timeout)) {
                if (hdev->reset_on_lockup)
                        device_reset = true;
@@ -822,8 +824,6 @@ static void cs_timedout(struct work_struct *work)
                cs->timedout = true;
        }
 
-       hdev = cs->ctx->hdev;
-
        /* Save only the first CS timeout parameters */
        rc = atomic_cmpxchg(&hdev->last_error.cs_timeout.write_enable, 1, 0);
        if (rc) {