From f5f79ed6d426809ef7ad4dc06bbdf7d2ba1bd9bc Mon Sep 17 00:00:00 2001
From: Junchong Pan <panjunchong@hisilicon.com>
Date: Fri, 4 Mar 2022 02:22:19 +0000
Subject: [PATCH 080/109] uadk/wd: fixup about checking device

Add non-empty check for ctx->dev.

Signed-off-by: Junchong Pan <panjunchong@hisilicon.com>
---
 wd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/wd.c b/wd.c
index 565c173..b88ee62 100644
--- a/wd.c
+++ b/wd.c
@@ -480,7 +480,7 @@ char *wd_ctx_get_api(handle_t h_ctx)
 {
 	struct wd_ctx_h	*ctx = (struct wd_ctx_h *)h_ctx;
 
-	if (!ctx)
+	if (!ctx || !ctx->dev)
 		return NULL;
 
 	return ctx->dev->api;
@@ -508,7 +508,7 @@ int wd_is_sva(handle_t h_ctx)
 {
 	struct wd_ctx_h	*ctx = (struct wd_ctx_h *)h_ctx;
 
-	if (!ctx)
+	if (!ctx || !ctx->dev)
 		return -WD_EINVAL;
 
 	if ((unsigned int)ctx->dev->flags & UACCE_DEV_SVA)
@@ -521,7 +521,7 @@ int wd_get_numa_id(handle_t h_ctx)
 {
 	struct wd_ctx_h	*ctx = (struct wd_ctx_h *)h_ctx;
 
-	if (!ctx)
+	if (!ctx || !ctx->dev)
 		return -WD_EINVAL;
 
 	return ctx->dev->numa_id;
-- 
2.27.0

