habanalabs: fix NULL dereference on cs timeout

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>
This commit is contained in:
Yuri Nudelman
2022-06-14 15:14:20 +03:00
committed by Oded Gabbay
parent 01622098ae
commit a189977701
@@ -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) {