gpu: nvgpu: Do not access NULL pointer dev

In gk20a_busy() we check if dev is NULL and return -ENODEV if so. But
before that we've already dereferenced dev by passing it to
get_gk20a(). Defer call to get_gk20a() until after the NULL check.

Bug 200192125

Change-Id: I943a9e96d13ff8cb4333fe20a941c8e95d159a66
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1280349
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Terje Bergstrom
2017-01-04 12:51:38 -08:00
committed by mobile promotions
parent 8f2f5ba865
commit e3e2786567

View File

@@ -1,7 +1,7 @@
/*
* GK20A Graphics
*
* Copyright (c) 2011-2016, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2011-2017, NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -1791,12 +1791,13 @@ static int gk20a_can_busy(struct gk20a *g)
int gk20a_busy(struct device *dev)
{
int ret = 0;
struct gk20a *g = get_gk20a(dev);
struct gk20a *g;
struct gk20a_platform *platform;
if (!dev)
return -ENODEV;
g = get_gk20a(dev);
platform = gk20a_get_platform(dev);
if (!g || !gk20a_can_busy(g))