From: "Marcin Ślusarz" <marcin.slusarz@arm.com>
To: Boris Brezillon <boris.brezillon@collabora.com>
Cc: Steven Price <steven.price@arm.com>,
dri-devel@lists.freedesktop.org,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Faith Ekstrand <faith.ekstrand@collabora.com>,
kernel@collabora.com, nd@arm.com
Subject: Re: [PATCH v4 11/14] drm/panfrost: Add a PANFROST_SYNC_BO ioctl
Date: Thu, 16 Oct 2025 10:42:21 +0200 [thread overview]
Message-ID: <aPCv7ZZ3t2fJvG4W@e129842.arm.com> (raw)
In-Reply-To: <20251015160326.3657287-12-boris.brezillon@collabora.com>
On Wed, Oct 15, 2025 at 06:03:23PM +0200, Boris Brezillon wrote:
> +static int panfrost_ioctl_sync_bo(struct drm_device *ddev, void *data,
> + struct drm_file *file)
> +{
> + struct drm_panfrost_sync_bo *args = data;
> + struct drm_panfrost_bo_sync_op *ops;
> + struct drm_gem_object *obj;
> + int ret;
> + u32 i;
> +
> + if (args->pad)
> + return -EINVAL;
> +
> + ops = kvmalloc_array(args->op_count, sizeof(*ops), GFP_KERNEL);
> + if (!ops) {
> + DRM_DEBUG("Failed to allocate incoming BO sync ops array\n");
> + return -ENOMEM;
> + }
> +
> + if (copy_from_user(ops, (void __user *)(uintptr_t)args->ops,
> + args->op_count * sizeof(*ops))) {
> + DRM_DEBUG("Failed to copy in BO sync ops\n");
> + ret = -EFAULT;
> + goto err_ops;
> + }
> +
> + for (i = 0; i < args->op_count; i++) {
If args->op_count is 0, if I'm not mistaken, kvmalloc_array and
copy_to_user will succeed, but then this function will return
unitialized value. Maybe add an explicit check for op_count == 0
at the beginning and avoid going through all that code?
> + if (ops[i].flags & ~PANFROST_BO_SYNC_OP_FLAGS) {
> + ret = -EINVAL;
> + goto err_ops;
> + }
> +
> + obj = drm_gem_object_lookup(file, ops[i].handle);
> + if (!obj) {
> + ret = -ENOENT;
> + goto err_ops;
> + }
> +
> + ret = panfrost_gem_sync(obj, ops[i].flags,
> + ops[i].offset, ops[i].size);
> +
> + drm_gem_object_put(obj);
> +
> + if (ret)
> + goto err_ops;
> + }
> +
> +err_ops:
> + kvfree(ops);
> +
> + return ret;
> +}
next prev parent reply other threads:[~2025-10-16 8:43 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-15 16:03 [PATCH v4 00/14] drm/panfrost, panthor: Cached maps and explicit flushing Boris Brezillon
2025-10-15 16:03 ` [PATCH v4 01/14] drm/panthor: Fix panthor_gpu_coherency_set() Boris Brezillon
2025-10-15 16:03 ` [PATCH v4 02/14] drm/gem: Add a drm_gem_object_funcs::sync() and a drm_gem_sync() helper Boris Brezillon
2025-10-16 8:13 ` Maxime Ripard
2025-10-16 12:57 ` Boris Brezillon
2025-10-16 13:07 ` Boris Brezillon
2025-10-29 9:30 ` Maxime Ripard
2025-10-30 14:07 ` Boris Brezillon
2025-10-16 8:32 ` Thomas Zimmermann
2025-10-16 9:40 ` Boris Brezillon
2025-10-16 9:58 ` Thomas Zimmermann
2025-10-16 10:32 ` Boris Brezillon
2025-10-16 11:42 ` Thomas Zimmermann
2025-10-16 12:24 ` Boris Brezillon
2025-10-30 14:11 ` Boris Brezillon
2025-10-17 14:32 ` Faith Ekstrand
2025-10-17 14:40 ` Faith Ekstrand
2025-10-17 15:26 ` Boris Brezillon
2025-10-17 15:35 ` Faith Ekstrand
2025-10-17 15:50 ` Boris Brezillon
2025-10-17 15:57 ` Faith Ekstrand
2025-10-17 16:35 ` Boris Brezillon
2025-10-15 16:03 ` [PATCH v4 03/14] drm/prime: Provide default ::{begin, end}_cpu_access() implementations Boris Brezillon
2025-10-15 16:03 ` [PATCH v4 04/14] drm/shmem: Add a drm_gem_shmem_sync() helper Boris Brezillon
2025-10-15 16:03 ` [PATCH v4 05/14] drm/panthor: Expose the selected coherency protocol to the UMD Boris Brezillon
2025-10-15 16:03 ` [PATCH v4 06/14] drm/panthor: Add a PANTHOR_BO_SYNC ioctl Boris Brezillon
2025-10-15 16:03 ` [PATCH v4 07/14] drm/panthor: Add an ioctl to query BO flags Boris Brezillon
2025-10-15 16:03 ` [PATCH v4 08/14] drm/panthor: Add flag to map GEM object Write-Back Cacheable Boris Brezillon
2025-10-15 16:03 ` [PATCH v4 09/14] drm/panthor: Bump the driver version to 1.6 Boris Brezillon
2025-10-15 16:03 ` [PATCH v4 10/14] drm/panfrost: Expose the selected coherency protocol to the UMD Boris Brezillon
2025-10-15 16:06 ` Steven Price
2025-10-15 16:03 ` [PATCH v4 11/14] drm/panfrost: Add a PANFROST_SYNC_BO ioctl Boris Brezillon
2025-10-16 8:42 ` Marcin Ślusarz [this message]
2025-10-16 9:52 ` Boris Brezillon
2025-10-16 10:02 ` Marcin Ślusarz
2025-10-16 10:35 ` Boris Brezillon
2025-10-15 16:03 ` [PATCH v4 12/14] drm/panfrost: Add an ioctl to query BO flags Boris Brezillon
2025-10-15 16:03 ` [PATCH v4 13/14] drm/panfrost: Add flag to map GEM object Write-Back Cacheable Boris Brezillon
2025-10-15 16:06 ` Steven Price
2025-10-15 16:03 ` [PATCH v4 14/14] drm/panfrost: Bump the driver version to 1.6 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=aPCv7ZZ3t2fJvG4W@e129842.arm.com \
--to=marcin.slusarz@arm.com \
--cc=airlied@gmail.com \
--cc=boris.brezillon@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=faith.ekstrand@collabora.com \
--cc=kernel@collabora.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=nd@arm.com \
--cc=simona@ffwll.ch \
--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