From c7b7dbe39a598aa228e4aaea4aec3ce958a27187 Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Wed, 3 Jan 2018 23:55:50 -0800 Subject: gpu: nvgpu: return error code in failure cases In gk20a_ce_create_context(), if gk20a_tsg_open() or gk20a_open_new_channel() fails, we bail out from the function without setting the error code This could mislead the caller and report incorrect success Fix this by setting error code explicitly in failure cases Bug 200374011 Change-Id: Idf6cba4a57740107bada698295745352f7b5d5ac Signed-off-by: Deepak Nibade Reviewed-on: https://git-master.nvidia.com/r/1631506 Reviewed-by: svc-mobile-coverity GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gk20a/ce2_gk20a.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/gpu/nvgpu/gk20a/ce2_gk20a.c') diff --git a/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c b/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c index 99a6dd1b..fd298bbf 100644 --- a/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c @@ -457,9 +457,9 @@ u32 gk20a_ce_create_context(struct gk20a *g, /* allocate a tsg if needed */ ce_ctx->tsg = gk20a_tsg_open(g); - if (!ce_ctx->tsg) { nvgpu_err(g, "ce: gk20a tsg not available"); + err = -ENOMEM; goto end; } @@ -467,6 +467,7 @@ u32 gk20a_ce_create_context(struct gk20a *g, ce_ctx->ch = gk20a_open_new_channel(g, runlist_id, true); if (!ce_ctx->ch) { nvgpu_err(g, "ce: gk20a channel not available"); + err = -ENOMEM; goto end; } ce_ctx->ch->wdt_enabled = false; -- cgit v1.2.2