From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: Daniel Stone <daniels@collabora.com>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 7/7] drm/mode: Add user blob-creation ioctl
Date: Thu, 07 May 2015 09:53:05 +0200 [thread overview]
Message-ID: <554B19E1.1000403@linux.intel.com> (raw)
In-Reply-To: <1429554176-9865-8-git-send-email-daniels@collabora.com>
Op 20-04-15 om 20:22 schreef Daniel Stone:
> Add an ioctl which allows users to create blob properties from supplied
> data. Currently this only supports modes, creating a drm_display_mode from
> the userspace drm_mode_modeinfo.
>
> Signed-off-by: Daniel Stone <daniels@collabora.com>
> ---
> <snip>
> +int drm_mode_createblob_ioctl(struct drm_device *dev,
> + void *data, struct drm_file *file_priv)
> +{
> + struct drm_mode_create_blob *out_resp = data;
> + struct drm_property_blob *blob;
> + void *blob_data;
> + int ret = 0;
> + void __user *blob_ptr;
> +
> + if (!drm_core_check_feature(dev, DRIVER_MODESET))
> + return -EINVAL;
> +
> + switch (out_resp->type) {
> + case DRM_MODE_BLOB_TYPE_MODE: {
> + if (out_resp->length != sizeof(struct drm_mode_modeinfo)) {
> + ret = -E2BIG;to length
You want -EINVAL here, -E2BIG means "argument list too long".
> + goto out_unlocked;
> + }
> + break;
> + }
> + default:
> + ret = -EINVAL;
> + goto out_unlocked;
> + }
> +
> + blob_data = kzalloc(out_resp->length, GFP_USER);
> + if (!blob_data) {
> + ret = -ENOMEM;
> + goto out_unlocked;
> + }
> +
> + blob_ptr = (void __user *)(unsigned long)out_resp->data;
> + if (copy_from_user(blob_data, blob_ptr, out_resp->length)) {
> + ret = -EFAULT;
> + goto out_data;
> + }
> +
> + blob = drm_property_create_blob(dev, out_resp->length, blob_data);
> + if (!blob) {
> + ret = -EINVAL;
drm_property_create_blob can fail from -ENOMEM or -EINVAL here, so correctly return the error from drm_property_create_blob?
You're also doing a double allocation, one for blob_ptr and the other for blob. It might be better to do a single allocation of the blob and copy
the data to blob->data directly.
For the whole series if this patch is fixed up:
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2015-05-07 7:53 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-20 18:22 [PATCH 0/7] User-created blob properties Daniel Stone
2015-04-20 18:22 ` [PATCH 1/7] drm/atomic: Don't open-code CRTC state destroy Daniel Stone
2015-04-20 18:22 ` [PATCH 2/7] drm/atomic: Early-exit from CRTC dup state Daniel Stone
2015-05-07 9:05 ` Daniel Vetter
2015-04-20 18:22 ` [PATCH 3/7] drm: Don't leak path blob property when updating Daniel Stone
2015-04-20 18:22 ` [PATCH 4/7] drm: Introduce helper for replacing blob properties Daniel Stone
2015-04-20 18:22 ` [PATCH 5/7] drm: Introduce blob_lock Daniel Stone
2015-04-20 18:22 ` [PATCH 6/7] drm: Add reference counting to blob properties Daniel Stone
2015-05-07 9:14 ` Daniel Vetter
2015-04-20 18:22 ` [PATCH 7/7] drm/mode: Add user blob-creation ioctl Daniel Stone
2015-05-07 7:53 ` Maarten Lankhorst [this message]
2015-05-07 8:34 ` [PATCH 0/7] User-created blob properties Daniel Vetter
2015-05-07 9:15 ` Daniel Stone
2015-05-09 14:52 ` [PATCH v2] " Daniel Stone
2015-05-09 14:52 ` [PATCH 1/4] drm: Remove extraneous parameter from kerneldoc Daniel Stone
2015-05-11 9:09 ` Daniel Vetter
2015-05-11 22:49 ` Daniel Stone
2015-05-09 14:52 ` [PATCH 2/4] drm: Allow creating blob properties without copy Daniel Stone
2015-05-09 14:52 ` [PATCH 3/4] drm: Return error value from blob creation Daniel Stone
2015-05-09 14:52 ` [PATCH 4/4] drm/mode: Add user blob-creation ioctl Daniel Stone
2015-05-11 9:11 ` Daniel Vetter
2015-05-11 22:46 ` [PATCH 7/7] " Daniel Stone
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=554B19E1.1000403@linux.intel.com \
--to=maarten.lankhorst@linux.intel.com \
--cc=daniels@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
/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