diff options
author | Kevin Huang <kevinh@nvidia.com> | 2014-07-14 18:27:34 -0400 |
---|---|---|
committer | Dan Willemsen <dwillemsen@nvidia.com> | 2015-03-18 15:10:40 -0400 |
commit | 7812a11903a9c0906370dad00fc092539e2219b9 (patch) | |
tree | 5d63ec073b3d263e51d0063c2da02c677c2c3863 /drivers/gpu/nvgpu | |
parent | 7aa2da0270d0b511ba26c3da0528c1b2fa593bba (diff) |
gpu: nvgpu: gk20a: add address check in allocator.
Check the address range before allocation to avoid illegal address
range.
Bug 1523403
Change-Id: Iff171399a980b69f9b1a18eea5bc37eff4c5d749
Signed-off-by: Kevin Huang <kevinh@nvidia.com>
Reviewed-on: http://git-master/r/437871
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a_allocator.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_allocator.c b/drivers/gpu/nvgpu/gk20a/gk20a_allocator.c index 32c003b6..d836dbcf 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a_allocator.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a_allocator.c | |||
@@ -922,7 +922,8 @@ int gk20a_allocator_block_alloc(struct gk20a_allocator *allocator, | |||
922 | 922 | ||
923 | allocator_dbg(allocator, "[in] addr %d, len %d", *addr, len); | 923 | allocator_dbg(allocator, "[in] addr %d, len %d", *addr, len); |
924 | 924 | ||
925 | if (*addr + len > allocator->limit || /* check addr range */ | 925 | if ((*addr != 0 && *addr < allocator->base) || /* check addr range */ |
926 | *addr + len > allocator->limit || /* check addr range */ | ||
926 | *addr & (allocator->align - 1) || /* check addr alignment */ | 927 | *addr & (allocator->align - 1) || /* check addr alignment */ |
927 | len == 0) /* check len */ | 928 | len == 0) /* check len */ |
928 | return -EINVAL; | 929 | return -EINVAL; |