mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 10:34:43 +03:00
gpu: nvgpu: Fix bitmap_allocator zero length bugs
Currently, function nvgpu_bitmap_allocator_init() initializes bitmap with length=0 but will fail in alloc(). Function alloc() allocates len=0 bitmap and next request also starts from same address. However, rbtree only holds zero length allocation. This patch adds length = 0 check in nvgpu_bitmap_allocator_init() and alloc() functions. JIRA NVGPU-3086 Change-Id: I0936977cd193f3eba00bba28edae257e40af23bf Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2087077 Reviewed-by: Nicolas Benech <nbenech@nvidia.com> Reviewed-by: svc-misra-checker <svc-misra-checker@nvidia.com> Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
7d60eb5bf0
commit
1f27acb983
@@ -209,6 +209,11 @@ static u64 nvgpu_bitmap_alloc(struct nvgpu_allocator *na, u64 len)
|
||||
unsigned long offs, adjusted_offs, limit;
|
||||
struct nvgpu_bitmap_allocator *a = bitmap_allocator(na);
|
||||
|
||||
if (len == 0ULL) {
|
||||
alloc_dbg(na, "len = 0, Alloc failed!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
tmp_u64 = len >> a->blk_shift;
|
||||
nvgpu_assert(tmp_u64 <= U32_MAX);
|
||||
blks = (u32)tmp_u64;
|
||||
@@ -405,6 +410,10 @@ int nvgpu_bitmap_allocator_init(struct gk20a *g, struct nvgpu_allocator *na,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (length == 0ULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (base == 0ULL) {
|
||||
base = blk_size;
|
||||
length -= blk_size;
|
||||
|
||||
Reference in New Issue
Block a user