mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 02:22:34 +03:00
gpu: nvgpu: Fix error handling of __semaphore_bitmap_alloc()
The return from __semaphore_bitmap_alloc() is an int for which a negative value indicates a failure. That return value was being directly cast to an unsigned int before being checked for a negative error code. This obviously isn't a good idea. Coverity ID 38754 Change-Id: I50c0478e5504988b059e69b929e9c2e465df7cc0 Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: http://git-master/r/1210317 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
9247b610d2
commit
0ea97181f2
@@ -122,7 +122,7 @@ struct gk20a_semaphore_pool *gk20a_semaphore_pool_alloc(
|
||||
{
|
||||
struct gk20a_semaphore_pool *p;
|
||||
unsigned long page_idx;
|
||||
int err = 0;
|
||||
int ret, err = 0;
|
||||
|
||||
p = kzalloc(sizeof(*p), GFP_KERNEL);
|
||||
if (!p)
|
||||
@@ -130,13 +130,14 @@ struct gk20a_semaphore_pool *gk20a_semaphore_pool_alloc(
|
||||
|
||||
__lock_sema_sea(sea);
|
||||
|
||||
page_idx = __semaphore_bitmap_alloc(sea->pools_alloced,
|
||||
SEMAPHORE_POOL_COUNT);
|
||||
if (page_idx < 0) {
|
||||
err = page_idx;
|
||||
ret = __semaphore_bitmap_alloc(sea->pools_alloced, SEMAPHORE_POOL_COUNT);
|
||||
if (ret < 0) {
|
||||
err = ret;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
page_idx = (unsigned long)ret;
|
||||
|
||||
p->page = sea->sea_mem.pages[page_idx];
|
||||
p->ro_sg_table = sea->ro_sg_table;
|
||||
p->page_idx = page_idx;
|
||||
|
||||
Reference in New Issue
Block a user