diff options
author | Terje Bergstrom <tbergstrom@nvidia.com> | 2017-01-04 15:51:38 -0500 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-01-06 12:13:59 -0500 |
commit | e3e2786567c9066ccf612b7c421ad0f52ebb82ba (patch) | |
tree | 01ab7672864b8e4fab330cb7ec8b846f85a4f7a5 /drivers | |
parent | 8f2f5ba8655ffb8b94471553c144d55eb3624a8f (diff) |
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
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c index 246338d4..b1e90bd8 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * GK20A Graphics | 2 | * GK20A Graphics |
3 | * | 3 | * |
4 | * Copyright (c) 2011-2016, NVIDIA CORPORATION. All rights reserved. | 4 | * Copyright (c) 2011-2017, NVIDIA CORPORATION. All rights reserved. |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify it | 6 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms and conditions of the GNU General Public License, | 7 | * under the terms and conditions of the GNU General Public License, |
@@ -1791,12 +1791,13 @@ static int gk20a_can_busy(struct gk20a *g) | |||
1791 | int gk20a_busy(struct device *dev) | 1791 | int gk20a_busy(struct device *dev) |
1792 | { | 1792 | { |
1793 | int ret = 0; | 1793 | int ret = 0; |
1794 | struct gk20a *g = get_gk20a(dev); | 1794 | struct gk20a *g; |
1795 | struct gk20a_platform *platform; | 1795 | struct gk20a_platform *platform; |
1796 | 1796 | ||
1797 | if (!dev) | 1797 | if (!dev) |
1798 | return -ENODEV; | 1798 | return -ENODEV; |
1799 | 1799 | ||
1800 | g = get_gk20a(dev); | ||
1800 | platform = gk20a_get_platform(dev); | 1801 | platform = gk20a_get_platform(dev); |
1801 | 1802 | ||
1802 | if (!g || !gk20a_can_busy(g)) | 1803 | if (!g || !gk20a_can_busy(g)) |