Skip to content

Commit 45c734f

Browse files
harshimogalapallibbrezillon
authored andcommitted
drm/panthor: Don't return NULL from panthor_vm_get_heap_pool()
The kernel doc says this function returns either a valid pointer or an ERR_PTR(), but in practice this function can return NULL if create=false. Fix the function to match the doc (return ERR_PTR(-ENOENT) instead of NULL) and adjust all call-sites accordingly. Fixes: 4bdca11 ("drm/panthor: Add the driver frontend block") Signed-off-by: Harshit Mogalapalli <[email protected]> Reviewed-by: Boris Brezillon <[email protected]> Signed-off-by: Boris Brezillon <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 6e0718f commit 45c734f

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

drivers/gpu/drm/panthor/panthor_drv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,8 +1090,8 @@ static int panthor_ioctl_tiler_heap_destroy(struct drm_device *ddev, void *data,
10901090
return -EINVAL;
10911091

10921092
pool = panthor_vm_get_heap_pool(vm, false);
1093-
if (!pool) {
1094-
ret = -EINVAL;
1093+
if (IS_ERR(pool)) {
1094+
ret = PTR_ERR(pool);
10951095
goto out_put_vm;
10961096
}
10971097

drivers/gpu/drm/panthor/panthor_mmu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,6 +1897,8 @@ struct panthor_heap_pool *panthor_vm_get_heap_pool(struct panthor_vm *vm, bool c
18971897
vm->heaps.pool = panthor_heap_pool_get(pool);
18981898
} else {
18991899
pool = panthor_heap_pool_get(vm->heaps.pool);
1900+
if (!pool)
1901+
pool = ERR_PTR(-ENOENT);
19001902
}
19011903
mutex_unlock(&vm->heaps.lock);
19021904

drivers/gpu/drm/panthor/panthor_sched.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,7 @@ static int group_process_tiler_oom(struct panthor_group *group, u32 cs_id)
13431343
if (unlikely(csg_id < 0))
13441344
return 0;
13451345

1346-
if (!heaps || frag_end > vt_end || vt_end >= vt_start) {
1346+
if (IS_ERR(heaps) || frag_end > vt_end || vt_end >= vt_start) {
13471347
ret = -EINVAL;
13481348
} else {
13491349
/* We do the allocation without holding the scheduler lock to avoid

0 commit comments

Comments
 (0)