[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <a35a0ae3-f976-4a74-aba0-2b16ecf2a61b@oracle.com>
Date: Wed, 3 Apr 2024 12:53:15 +0530
From: Harshit Mogalapalli <harshit.m.mogalapalli@...cle.com>
To: Boris Brezillon <boris.brezillon@...labora.com>
Cc: Steven Price <steven.price@....com>, Liviu Dudau <liviu.dudau@....com>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...il.com>, Daniel Vetter <daniel@...ll.ch>,
Heiko Stuebner <heiko@...ech.de>,
Grant Likely <grant.likely@...aro.org>,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
dan.carpenter@...aro.org, kernel-janitors@...r.kernel.org,
error27@...il.com
Subject: Re: [PATCH v3] drm/panthor: Fix couple of NULL vs IS_ERR() bugs
Hi Boris,
On 03/04/24 12:47, Boris Brezillon wrote:
> On Tue, 2 Apr 2024 07:14:11 -0700
> Harshit Mogalapalli <harshit.m.mogalapalli@...cle.com> wrote:
>
>> Currently panthor_vm_get_heap_pool() returns both ERR_PTR() and
>> NULL(when create is false and if there is no poool attached to the
>> VM)
>> - Change the function to return error pointers, when pool is
>> NULL return -ENOENT
>> - Also handle the callers to check for IS_ERR() on failure.
>>
>> Fixes: 4bdca1150792 ("drm/panthor: Add the driver frontend block")
>> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@...cle.com>
>
> Queued to drm-misc-next with the following commit message:
>
> "
> 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.
> "
>
Thanks a lot for making the change!
Regards,
Harshit
> Thanks,
>
> Boris
>
>> ---
>> This is spotted by smatch and the patch is only compile tested
>>
>> v1->v2: Fix the function panthor_vm_get_heap_pool() to only return error
>> pointers and handle the caller sites [Suggested by Boris Brezillon]
>> - Also merge these IS_ERR() vs NULL bugs into same patch
>>
>> v2->v3: pull out error checking for devm_drm_dev_alloc() failure.
>> ---
>> drivers/gpu/drm/panthor/panthor_drv.c | 4 ++--
>> drivers/gpu/drm/panthor/panthor_mmu.c | 2 ++
>> drivers/gpu/drm/panthor/panthor_sched.c | 2 +-
>> 3 files changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
>> index 11b3ccd58f85..050b905b0453 100644
>> --- a/drivers/gpu/drm/panthor/panthor_drv.c
>> +++ b/drivers/gpu/drm/panthor/panthor_drv.c
>> @@ -1090,8 +1090,8 @@ static int panthor_ioctl_tiler_heap_destroy(struct drm_device *ddev, void *data,
>> return -EINVAL;
>>
>> pool = panthor_vm_get_heap_pool(vm, false);
>> - if (!pool) {
>> - ret = -EINVAL;
>> + if (IS_ERR(pool)) {
>> + ret = PTR_ERR(pool);
>> goto out_put_vm;
>> }
>>
>> diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c
>> index fdd35249169f..e1285cdb09ff 100644
>> --- a/drivers/gpu/drm/panthor/panthor_mmu.c
>> +++ b/drivers/gpu/drm/panthor/panthor_mmu.c
>> @@ -1893,6 +1893,8 @@ struct panthor_heap_pool *panthor_vm_get_heap_pool(struct panthor_vm *vm, bool c
>> vm->heaps.pool = panthor_heap_pool_get(pool);
>> } else {
>> pool = panthor_heap_pool_get(vm->heaps.pool);
>> + if (!pool)
>> + pool = ERR_PTR(-ENOENT);
>> }
>> mutex_unlock(&vm->heaps.lock);
>>
>> diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
>> index 5f7803b6fc48..617df2b980d0 100644
>> --- a/drivers/gpu/drm/panthor/panthor_sched.c
>> +++ b/drivers/gpu/drm/panthor/panthor_sched.c
>> @@ -1343,7 +1343,7 @@ static int group_process_tiler_oom(struct panthor_group *group, u32 cs_id)
>> if (unlikely(csg_id < 0))
>> return 0;
>>
>> - if (!heaps || frag_end > vt_end || vt_end >= vt_start) {
>> + if (IS_ERR(heaps) || frag_end > vt_end || vt_end >= vt_start) {
>> ret = -EINVAL;
>> } else {
>> /* We do the allocation without holding the scheduler lock to avoid
>
Powered by blists - more mailing lists