From: Yuri Nudelman Date: Tue, 14 Jun 2022 12:14:20 +0000 (+0300) Subject: habanalabs: fix NULL dereference on cs timeout X-Git-Tag: baikal/mips/sdk6.1~5150^2~27^2~68 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=ff4abb4f0d4bd3ec74354f3e7315d31c3c4d2a41;p=kernel.git habanalabs: fix NULL dereference on cs timeout Device descriptor is accessed before an assignment Signed-off-by: Yuri Nudelman Reviewed-by: Oded Gabbay Signed-off-by: Oded Gabbay --- diff --git a/drivers/misc/habanalabs/common/command_submission.c b/drivers/misc/habanalabs/common/command_submission.c index 72a557b83a7dd..c050f38b7091f 100644 --- a/drivers/misc/habanalabs/common/command_submission.c +++ b/drivers/misc/habanalabs/common/command_submission.c @@ -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) {