dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] drm: Don't create properties without names
@ 2018-03-02 13:25 Ville Syrjala
  2018-03-02 13:25 ` [PATCH 2/3] drm: Check property/enum name length Ville Syrjala
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Ville Syrjala @ 2018-03-02 13:25 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Creating a property that doesn't have a name makes no sense to me. Don't
allow it.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_property.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c
index bae50e6b819d..fe8627fb7ae6 100644
--- a/drivers/gpu/drm/drm_property.c
+++ b/drivers/gpu/drm/drm_property.c
@@ -99,10 +99,8 @@ struct drm_property *drm_property_create(struct drm_device *dev, int flags,
 	property->num_values = num_values;
 	INIT_LIST_HEAD(&property->enum_list);
 
-	if (name) {
-		strncpy(property->name, name, DRM_PROP_NAME_LEN);
-		property->name[DRM_PROP_NAME_LEN-1] = '\0';
-	}
+	strncpy(property->name, name, DRM_PROP_NAME_LEN);
+	property->name[DRM_PROP_NAME_LEN-1] = '\0';
 
 	list_add_tail(&property->head, &dev->mode_config.property_list);
 
-- 
2.13.6

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/3] drm: Check property/enum name length
  2018-03-02 13:25 [PATCH 1/3] drm: Don't create properties without names Ville Syrjala
@ 2018-03-02 13:25 ` Ville Syrjala
  2018-03-02 14:03   ` [PATCH v2 2/3 " Ville Syrjala
  2018-03-02 13:25 ` [PATCH v2 3/3] drm: Add BT.2020 constant luminance enum value for the COLOR_ENCODING property Ville Syrjala
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Ville Syrjala @ 2018-03-02 13:25 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reject requests to add properties/enums with an overly long name.
Previously we would have just silently truncated the string and exposed
it userspace.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_property.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c
index fe8627fb7ae6..f062adf21b9c 100644
--- a/drivers/gpu/drm/drm_property.c
+++ b/drivers/gpu/drm/drm_property.c
@@ -78,6 +78,9 @@ struct drm_property *drm_property_create(struct drm_device *dev, int flags,
 	struct drm_property *property = NULL;
 	int ret;
 
+	if (WARN_ON(strlen(name) >= DRM_PROP_NAME_LEN))
+		return -EINVAL;
+
 	property = kzalloc(sizeof(struct drm_property), GFP_KERNEL);
 	if (!property)
 		return NULL;
@@ -372,6 +375,9 @@ int drm_property_add_enum(struct drm_property *property, int index,
 {
 	struct drm_property_enum *prop_enum;
 
+	if (WARN_ON(strlen(name) >= DRM_PROP_NAME_LEN))
+		return -EINVAL;
+
 	if (!(drm_property_type_is(property, DRM_MODE_PROP_ENUM) ||
 			drm_property_type_is(property, DRM_MODE_PROP_BITMASK)))
 		return -EINVAL;
-- 
2.13.6

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 3/3] drm: Add BT.2020 constant luminance enum value for the COLOR_ENCODING property
  2018-03-02 13:25 [PATCH 1/3] drm: Don't create properties without names Ville Syrjala
  2018-03-02 13:25 ` [PATCH 2/3] drm: Check property/enum name length Ville Syrjala
@ 2018-03-02 13:25 ` Ville Syrjala
  2018-03-06 10:18 ` [PATCH 1/3] drm: Don't create properties without names Daniel Vetter
  2018-03-06 13:35 ` [Intel-gfx] " Emil Velikov
  3 siblings, 0 replies; 10+ messages in thread
From: Ville Syrjala @ 2018-03-02 13:25 UTC (permalink / raw)
  To: dri-devel
  Cc: intel-gfx, Russell King - ARM Linux, Hans Verkuil, Uma Shankar,
	Jyri Sarha

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

BT.2020 specifies two YCbCr<->RGB conversion formulas. The more
traditional non-constant luminance and a more complicate constant
luminance one. Add an enum value for the constant luminance variant
as well in case someone has hardware supporting it.

v2: Reduce the enum name to fit within the 31 character uapi limit

Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Daniel Stone <daniel@fooishbar.org>
Cc: Russell King - ARM Linux <linux@armlinux.org.uk>
Cc: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: Hans Verkuil <hverkuil@xs4all.nl>
CC: Uma Shankar <uma.shankar@intel.com>
Cc: Shashank Sharma <shashank.sharma@intel.com>
Cc: Jyri Sarha <jsarha@ti.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Acked-by: Harry Wentland <harry.wentland@amd.com> #v1
---
 drivers/gpu/drm/drm_color_mgmt.c | 1 +
 include/drm/drm_color_mgmt.h     | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
index 4ff064623836..cc28c32399af 100644
--- a/drivers/gpu/drm/drm_color_mgmt.c
+++ b/drivers/gpu/drm/drm_color_mgmt.c
@@ -358,6 +358,7 @@ static const char * const color_encoding_name[] = {
 	[DRM_COLOR_YCBCR_BT601] = "ITU-R BT.601 YCbCr",
 	[DRM_COLOR_YCBCR_BT709] = "ITU-R BT.709 YCbCr",
 	[DRM_COLOR_YCBCR_BT2020] = "ITU-R BT.2020 YCbCr",
+	[DRM_COLOR_YCBCR_BT2020_CONST] = "ITU-R BT.2020 YCbCr const",
 };
 
 static const char * const color_range_name[] = {
diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h
index b3b6d302ca8c..175943c87d5b 100644
--- a/include/drm/drm_color_mgmt.h
+++ b/include/drm/drm_color_mgmt.h
@@ -41,7 +41,8 @@ int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
 enum drm_color_encoding {
 	DRM_COLOR_YCBCR_BT601,
 	DRM_COLOR_YCBCR_BT709,
-	DRM_COLOR_YCBCR_BT2020,
+	DRM_COLOR_YCBCR_BT2020, /* non-constant luminance */
+	DRM_COLOR_YCBCR_BT2020_CONST, /* constant luminance */
 	DRM_COLOR_ENCODING_MAX,
 };
 
-- 
2.13.6

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 2/3 drm: Check property/enum name length
  2018-03-02 13:25 ` [PATCH 2/3] drm: Check property/enum name length Ville Syrjala
@ 2018-03-02 14:03   ` Ville Syrjala
  2018-03-06 10:22     ` [Intel-gfx] " Daniel Vetter
  0 siblings, 1 reply; 10+ messages in thread
From: Ville Syrjala @ 2018-03-02 14:03 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reject requests to add properties/enums with an overly long name.
Previously we would have just silently truncated the string and exposed
it userspace.

v2: drm_property_create() returns a pointer

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_property.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c
index fe8627fb7ae6..c37ac41125b5 100644
--- a/drivers/gpu/drm/drm_property.c
+++ b/drivers/gpu/drm/drm_property.c
@@ -78,6 +78,9 @@ struct drm_property *drm_property_create(struct drm_device *dev, int flags,
 	struct drm_property *property = NULL;
 	int ret;
 
+	if (WARN_ON(strlen(name) >= DRM_PROP_NAME_LEN))
+		return NULL;
+
 	property = kzalloc(sizeof(struct drm_property), GFP_KERNEL);
 	if (!property)
 		return NULL;
@@ -372,6 +375,9 @@ int drm_property_add_enum(struct drm_property *property, int index,
 {
 	struct drm_property_enum *prop_enum;
 
+	if (WARN_ON(strlen(name) >= DRM_PROP_NAME_LEN))
+		return -EINVAL;
+
 	if (!(drm_property_type_is(property, DRM_MODE_PROP_ENUM) ||
 			drm_property_type_is(property, DRM_MODE_PROP_BITMASK)))
 		return -EINVAL;
-- 
2.16.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] drm: Don't create properties without names
  2018-03-02 13:25 [PATCH 1/3] drm: Don't create properties without names Ville Syrjala
  2018-03-02 13:25 ` [PATCH 2/3] drm: Check property/enum name length Ville Syrjala
  2018-03-02 13:25 ` [PATCH v2 3/3] drm: Add BT.2020 constant luminance enum value for the COLOR_ENCODING property Ville Syrjala
@ 2018-03-06 10:18 ` Daniel Vetter
  2018-03-06 13:35 ` [Intel-gfx] " Emil Velikov
  3 siblings, 0 replies; 10+ messages in thread
From: Daniel Vetter @ 2018-03-06 10:18 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: intel-gfx, dri-devel

On Fri, Mar 02, 2018 at 03:25:42PM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Creating a property that doesn't have a name makes no sense to me. Don't
> allow it.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/drm_property.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c
> index bae50e6b819d..fe8627fb7ae6 100644
> --- a/drivers/gpu/drm/drm_property.c
> +++ b/drivers/gpu/drm/drm_property.c
> @@ -99,10 +99,8 @@ struct drm_property *drm_property_create(struct drm_device *dev, int flags,
>  	property->num_values = num_values;
>  	INIT_LIST_HEAD(&property->enum_list);
>  
> -	if (name) {
> -		strncpy(property->name, name, DRM_PROP_NAME_LEN);
> -		property->name[DRM_PROP_NAME_LEN-1] = '\0';
> -	}
> +	strncpy(property->name, name, DRM_PROP_NAME_LEN);
> +	property->name[DRM_PROP_NAME_LEN-1] = '\0';
>  
>  	list_add_tail(&property->head, &dev->mode_config.property_list);
>  
> -- 
> 2.13.6
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Intel-gfx] [PATCH v2 2/3 drm: Check property/enum name length
  2018-03-02 14:03   ` [PATCH v2 2/3 " Ville Syrjala
@ 2018-03-06 10:22     ` Daniel Vetter
  2018-03-06 11:50       ` Ville Syrjälä
  0 siblings, 1 reply; 10+ messages in thread
From: Daniel Vetter @ 2018-03-06 10:22 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: intel-gfx, dri-devel

On Fri, Mar 02, 2018 at 04:03:00PM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Reject requests to add properties/enums with an overly long name.
> Previously we would have just silently truncated the string and exposed
> it userspace.
> 
> v2: drm_property_create() returns a pointer
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

While you're typing validation code, I noticed that drm_property_add_enum
allows you to overwrite the name of an existing enum value already added.
That sounds like something we never want to allow either.

Anyway, this is

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/drm_property.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c
> index fe8627fb7ae6..c37ac41125b5 100644
> --- a/drivers/gpu/drm/drm_property.c
> +++ b/drivers/gpu/drm/drm_property.c
> @@ -78,6 +78,9 @@ struct drm_property *drm_property_create(struct drm_device *dev, int flags,
>  	struct drm_property *property = NULL;
>  	int ret;
>  
> +	if (WARN_ON(strlen(name) >= DRM_PROP_NAME_LEN))
> +		return NULL;
> +
>  	property = kzalloc(sizeof(struct drm_property), GFP_KERNEL);
>  	if (!property)
>  		return NULL;
> @@ -372,6 +375,9 @@ int drm_property_add_enum(struct drm_property *property, int index,
>  {
>  	struct drm_property_enum *prop_enum;
>  
> +	if (WARN_ON(strlen(name) >= DRM_PROP_NAME_LEN))
> +		return -EINVAL;
> +
>  	if (!(drm_property_type_is(property, DRM_MODE_PROP_ENUM) ||
>  			drm_property_type_is(property, DRM_MODE_PROP_BITMASK)))
>  		return -EINVAL;
> -- 
> 2.16.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/3 drm: Check property/enum name length
  2018-03-06 10:22     ` [Intel-gfx] " Daniel Vetter
@ 2018-03-06 11:50       ` Ville Syrjälä
  0 siblings, 0 replies; 10+ messages in thread
From: Ville Syrjälä @ 2018-03-06 11:50 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: intel-gfx, dri-devel

On Tue, Mar 06, 2018 at 11:22:54AM +0100, Daniel Vetter wrote:
> On Fri, Mar 02, 2018 at 04:03:00PM +0200, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > Reject requests to add properties/enums with an overly long name.
> > Previously we would have just silently truncated the string and exposed
> > it userspace.
> > 
> > v2: drm_property_create() returns a pointer
> > 
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> While you're typing validation code, I noticed that drm_property_add_enum
> allows you to overwrite the name of an existing enum value already added.
> That sounds like something we never want to allow either.

Good point. I suppose we should just WARN and error out there as well?

> 
> Anyway, this is
> 
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> 
> > ---
> >  drivers/gpu/drm/drm_property.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c
> > index fe8627fb7ae6..c37ac41125b5 100644
> > --- a/drivers/gpu/drm/drm_property.c
> > +++ b/drivers/gpu/drm/drm_property.c
> > @@ -78,6 +78,9 @@ struct drm_property *drm_property_create(struct drm_device *dev, int flags,
> >  	struct drm_property *property = NULL;
> >  	int ret;
> >  
> > +	if (WARN_ON(strlen(name) >= DRM_PROP_NAME_LEN))
> > +		return NULL;
> > +
> >  	property = kzalloc(sizeof(struct drm_property), GFP_KERNEL);
> >  	if (!property)
> >  		return NULL;
> > @@ -372,6 +375,9 @@ int drm_property_add_enum(struct drm_property *property, int index,
> >  {
> >  	struct drm_property_enum *prop_enum;
> >  
> > +	if (WARN_ON(strlen(name) >= DRM_PROP_NAME_LEN))
> > +		return -EINVAL;
> > +
> >  	if (!(drm_property_type_is(property, DRM_MODE_PROP_ENUM) ||
> >  			drm_property_type_is(property, DRM_MODE_PROP_BITMASK)))
> >  		return -EINVAL;
> > -- 
> > 2.16.1
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Intel-gfx] [PATCH 1/3] drm: Don't create properties without names
  2018-03-02 13:25 [PATCH 1/3] drm: Don't create properties without names Ville Syrjala
                   ` (2 preceding siblings ...)
  2018-03-06 10:18 ` [PATCH 1/3] drm: Don't create properties without names Daniel Vetter
@ 2018-03-06 13:35 ` Emil Velikov
  2018-03-06 13:54   ` Ville Syrjälä
  3 siblings, 1 reply; 10+ messages in thread
From: Emil Velikov @ 2018-03-06 13:35 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: intel-gfx, ML dri-devel

Hi Ville,

On 2 March 2018 at 13:25, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Creating a property that doesn't have a name makes no sense to me. Don't
> allow it.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_property.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c
> index bae50e6b819d..fe8627fb7ae6 100644
> --- a/drivers/gpu/drm/drm_property.c
> +++ b/drivers/gpu/drm/drm_property.c
> @@ -99,10 +99,8 @@ struct drm_property *drm_property_create(struct drm_device *dev, int flags,
>         property->num_values = num_values;
>         INIT_LIST_HEAD(&property->enum_list);
>
> -       if (name) {
> -               strncpy(property->name, name, DRM_PROP_NAME_LEN);
> -               property->name[DRM_PROP_NAME_LEN-1] = '\0';
> -       }
> +       strncpy(property->name, name, DRM_PROP_NAME_LEN);
> +       property->name[DRM_PROP_NAME_LEN-1] = '\0';
>
Shouldn't one also a) error (WARN + return NULL) out when name is NULL
and b) update the documentation?

-Emil
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Intel-gfx] [PATCH 1/3] drm: Don't create properties without names
  2018-03-06 13:35 ` [Intel-gfx] " Emil Velikov
@ 2018-03-06 13:54   ` Ville Syrjälä
  2018-03-06 15:41     ` Emil Velikov
  0 siblings, 1 reply; 10+ messages in thread
From: Ville Syrjälä @ 2018-03-06 13:54 UTC (permalink / raw)
  To: Emil Velikov; +Cc: intel-gfx, ML dri-devel

On Tue, Mar 06, 2018 at 01:35:11PM +0000, Emil Velikov wrote:
> Hi Ville,
> 
> On 2 March 2018 at 13:25, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Creating a property that doesn't have a name makes no sense to me. Don't
> > allow it.
> >
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/drm_property.c | 6 ++----
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c
> > index bae50e6b819d..fe8627fb7ae6 100644
> > --- a/drivers/gpu/drm/drm_property.c
> > +++ b/drivers/gpu/drm/drm_property.c
> > @@ -99,10 +99,8 @@ struct drm_property *drm_property_create(struct drm_device *dev, int flags,
> >         property->num_values = num_values;
> >         INIT_LIST_HEAD(&property->enum_list);
> >
> > -       if (name) {
> > -               strncpy(property->name, name, DRM_PROP_NAME_LEN);
> > -               property->name[DRM_PROP_NAME_LEN-1] = '\0';
> > -       }
> > +       strncpy(property->name, name, DRM_PROP_NAME_LEN);
> > +       property->name[DRM_PROP_NAME_LEN-1] = '\0';
> >
> Shouldn't one also a) error (WARN + return NULL) out when name is NULL
> and b) update the documentation?

The developer gets the oops. No point in further handholding IMO.

Didn't look at the docs us usual. Are they saying NULL is OK?

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] drm: Don't create properties without names
  2018-03-06 13:54   ` Ville Syrjälä
@ 2018-03-06 15:41     ` Emil Velikov
  0 siblings, 0 replies; 10+ messages in thread
From: Emil Velikov @ 2018-03-06 15:41 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx, ML dri-devel

On 6 March 2018 at 13:54, Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:
> On Tue, Mar 06, 2018 at 01:35:11PM +0000, Emil Velikov wrote:
>> Hi Ville,
>>
>> On 2 March 2018 at 13:25, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
>> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>> >
>> > Creating a property that doesn't have a name makes no sense to me. Don't
>> > allow it.
>> >
>> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>> > ---
>> >  drivers/gpu/drm/drm_property.c | 6 ++----
>> >  1 file changed, 2 insertions(+), 4 deletions(-)
>> >
>> > diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c
>> > index bae50e6b819d..fe8627fb7ae6 100644
>> > --- a/drivers/gpu/drm/drm_property.c
>> > +++ b/drivers/gpu/drm/drm_property.c
>> > @@ -99,10 +99,8 @@ struct drm_property *drm_property_create(struct drm_device *dev, int flags,
>> >         property->num_values = num_values;
>> >         INIT_LIST_HEAD(&property->enum_list);
>> >
>> > -       if (name) {
>> > -               strncpy(property->name, name, DRM_PROP_NAME_LEN);
>> > -               property->name[DRM_PROP_NAME_LEN-1] = '\0';
>> > -       }
>> > +       strncpy(property->name, name, DRM_PROP_NAME_LEN);
>> > +       property->name[DRM_PROP_NAME_LEN-1] = '\0';
>> >
>> Shouldn't one also a) error (WARN + return NULL) out when name is NULL
>> and b) update the documentation?
>
> The developer gets the oops. No point in further handholding IMO.
>
Gut feeling suggests that not everyone tests all their
drm_properly_create codepaths. So it's more of user gets an oops.
But that's another story ;-)

> Didn't look at the docs us usual. Are they saying NULL is OK?
>
The drm_property_create does not explicitly mention (allow?) NULL.
Yet again I don't recall any instances of the docs saying that, using
NULL is allowed/valid.

It's been a while since I read through the docs, so they might be updated.

Either way it was a simple fly-by suggestion.
-Emil
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-03-06 15:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-02 13:25 [PATCH 1/3] drm: Don't create properties without names Ville Syrjala
2018-03-02 13:25 ` [PATCH 2/3] drm: Check property/enum name length Ville Syrjala
2018-03-02 14:03   ` [PATCH v2 2/3 " Ville Syrjala
2018-03-06 10:22     ` [Intel-gfx] " Daniel Vetter
2018-03-06 11:50       ` Ville Syrjälä
2018-03-02 13:25 ` [PATCH v2 3/3] drm: Add BT.2020 constant luminance enum value for the COLOR_ENCODING property Ville Syrjala
2018-03-06 10:18 ` [PATCH 1/3] drm: Don't create properties without names Daniel Vetter
2018-03-06 13:35 ` [Intel-gfx] " Emil Velikov
2018-03-06 13:54   ` Ville Syrjälä
2018-03-06 15:41     ` Emil Velikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox