From: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
To: Boris Brezillon <boris.brezillon@collabora.com>
Cc: Steven Price <steven.price@arm.com>,
Liviu Dudau <liviu.dudau@arm.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
Heiko Stuebner <heiko@sntech.de>,
Grant Likely <grant.likely@linaro.org>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
dan.carpenter@linaro.org, kernel-janitors@vger.kernel.org,
error27@gmail.com
Subject: Re: [PATCH v2] drm/panthor: Fix couple of NULL vs IS_ERR() bugs
Date: Tue, 2 Apr 2024 19:35:41 +0530 [thread overview]
Message-ID: <b35d0de5-be46-42a1-b7e7-b24a72d945c7@oracle.com> (raw)
In-Reply-To: <20240402160226.4a1ac2d1@collabora.com>
Hi Boris,
On 02/04/24 19:32, Boris Brezillon wrote:
> On Tue, 2 Apr 2024 06:47:08 -0700
> Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com> wrote:
>
>> 1. The devm_drm_dev_alloc() function returns error pointers.
>> Update the error handling to check for error pointers instead of NULL.
>> 2. 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@oracle.com>
>> ---
>> 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
>> ---
>> drivers/gpu/drm/panthor/panthor_drv.c | 6 +++---
>> drivers/gpu/drm/panthor/panthor_mmu.c | 2 ++
>> drivers/gpu/drm/panthor/panthor_sched.c | 2 +-
>> 3 files changed, 6 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
>> index 11b3ccd58f85..c8374cd4a30d 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;
>> }
>>
>> @@ -1385,7 +1385,7 @@ static int panthor_probe(struct platform_device *pdev)
>>
>> ptdev = devm_drm_dev_alloc(&pdev->dev, &panthor_drm_driver,
>> struct panthor_device, base);
>> - if (!ptdev)
>> + if (IS_ERR(ptdev))
>> return -ENOMEM;
>>
>
> Sorry, that one deserves a separate patch.
>
Ah okay, I was confused about the same.
So I will send a V3 removing that part and could you please use the
independent patch that I sent before ?
https://lore.kernel.org/all/20240402104041.1689951-1-harshit.m.mogalapalli@oracle.com/
Thanks,
Harshit
>> platform_set_drvdata(pdev, ptdev);
>> 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
>
>
next prev parent reply other threads:[~2024-04-02 14:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-02 13:47 Harshit Mogalapalli
2024-04-02 14:02 ` Boris Brezillon
2024-04-02 14:05 ` Harshit Mogalapalli [this message]
2024-04-02 14:07 ` Boris Brezillon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b35d0de5-be46-42a1-b7e7-b24a72d945c7@oracle.com \
--to=harshit.m.mogalapalli@oracle.com \
--cc=airlied@gmail.com \
--cc=boris.brezillon@collabora.com \
--cc=dan.carpenter@linaro.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=error27@gmail.com \
--cc=grant.likely@linaro.org \
--cc=heiko@sntech.de \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liviu.dudau@arm.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=steven.price@arm.com \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®