Skip to contentSkip to conversation

drm: Don't create properties without names

PATCH In review Ville Syrjala 4 participants 14 messages Mar 2, 2018 – Mar 6, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 drm: Don't create properties without names

From: Ville Syrjälä <[email protected]>

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

---
 drivers/gpu/drm/drm_property.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_property.c +2 -4
index bae50e6b819d..fe8627fb7ae6 100644
@@ -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);
 
Signature · 6 lines
2.13.6

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/3 drm: Check property/enum name length

From: Ville Syrjälä <[email protected]>

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

---
 drivers/gpu/drm/drm_property.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/drm_property.c +6 -0
index fe8627fb7ae6..f062adf21b9c 100644
@@ -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;
Signature · 6 lines
2.13.6

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

[PATCH v2 2/3 drm: Check property/enum name length

From: Ville Syrjälä <[email protected]>

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

---
 drivers/gpu/drm/drm_property.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/drm_property.c +6 -0
index fe8627fb7ae6..c37ac41125b5 100644
@@ -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;
Signature · 6 lines
2.16.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by
#3 lore raw

Re: [Intel-gfx] [PATCH v2 2/3 drm: Check property/enum name length

Quoted 9 lines · Ville Syrjala

From: Ville Syrjälä <[email protected]>

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

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

Quoted 35 lines
---
 drivers/gpu/drm/drm_property.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/drm_property.c +6 -0
index fe8627fb7ae6..c37ac41125b5 100644
@@ -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;
Signature · 6 lines
2.16.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw

Re: [PATCH v2 2/3 drm: Check property/enum name length

Quoted 7 lines · Daniel Vetter
Quoted 6 lines · Ville Syrjala

From: Ville Syrjälä <[email protected]>

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

Quoted 7 lines
Quoted 3 lines

v2: drm_property_create() returns a pointer

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?

Quoted 45 lines

Anyway, this is

Quoted 35 lines
---
 drivers/gpu/drm/drm_property.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/drm_property.c +6 -0
index fe8627fb7ae6..c37ac41125b5 100644
@@ -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;
Signature · 6 lines
2.16.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

PATCH v2 3/3 drm: Add BT.2020 constant luminance enum value for the COLOR_ENCODING property

In reply to Ville Syrjala

From: Ville Syrjälä <[email protected]>

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 <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Daniel Stone <[email protected]>
Cc Russell King - ARM Linux <[email protected]>
Cc Ilia Mirkin <[email protected]>
Cc Hans Verkuil <[email protected]>
CC Uma Shankar <[email protected]>
Cc Shashank Sharma <[email protected]>
Cc Jyri Sarha <[email protected]>
---
 drivers/gpu/drm/drm_color_mgmt.c | 1 +
 include/drm/drm_color_mgmt.h     | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_color_mgmt.c +1 -0
index 4ff064623836..cc28c32399af 100644
@@ -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[] = {
include/drm/drm_color_mgmt.h +2 -1
index b3b6d302ca8c..175943c87d5b 100644
@@ -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,
 };
 
Signature · 6 lines
2.13.6

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#6 lore raw

✗ Fi.CI.SPARSE: warning for series starting with [1/3] drm: Don't create properties without names

In reply to Ville Syrjala
== Series Details ==

== Series Details ==

Series: series starting with [1/3] drm: Don't create properties without names
URL : https://patchwork.freedesktop.org/series/39277/
State : warning

== Summary ==

$ dim sparse origin/drm-tip
Commit: drm: Don't create properties without names
Okay!

Commit: drm: Check property/enum name length
-
+ ^
+drivers/gpu/drm/drm_property.c:82:10: warning: return makes pointer from integer without a cast [-Wint-conversion]
+drivers/gpu/drm/drm_property.c:82:24: expected struct drm_property *
+drivers/gpu/drm/drm_property.c:82:24: got int
+drivers/gpu/drm/drm_property.c:82:24: warning: incorrect type in return expression (different base types) +drivers/gpu/drm/drm_property.c: In function ‘drm_property_create’:
+ return -EINVAL;

Commit: drm: Add BT.2020 constant luminance enum value for the COLOR_ENCODING property Okay!

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#7 lore raw

✓ Fi.CI.BAT: success for series starting with [1/3] drm: Don't create properties without names

In reply to Ville Syrjala
== Series Details ==

== Series Details ==

Series: series starting with [1/3] drm: Don't create properties without names
URL : https://patchwork.freedesktop.org/series/39277/
State : success

== Summary ==

Series 39277v1 series starting with [1/3] drm: Don't create properties without names
https://patchwork.freedesktop.org/api/1.0/series/39277/revisions/1/mbox/

---- Known issues:

Test kms_pipe_crc_basic:

        Subgroup suspend-read-crc-pipe-b:
                pass       -> INCOMPLETE (fi-snb-2520m) fdo#103713

fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713

fi-bdw-5557u     total:288  pass:267  dwarn:0   dfail:0   fail:0   skip:21  time:412s
fi-bdw-gvtdvm    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:419s
fi-blb-e6850     total:288  pass:223  dwarn:1   dfail:0   fail:0   skip:64  time:371s
fi-bsw-n3050     total:288  pass:242  dwarn:0   dfail:0   fail:0   skip:46  time:494s
fi-bwr-2160      total:288  pass:183  dwarn:0   dfail:0   fail:0   skip:105 time:277s
fi-bxt-dsi       total:288  pass:258  dwarn:0   dfail:0   fail:0   skip:30  time:477s
fi-bxt-j4205     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:485s
fi-byt-j1900     total:288  pass:253  dwarn:0   dfail:0   fail:0   skip:35  time:463s
fi-byt-n2820     total:288  pass:249  dwarn:0   dfail:0   fail:0   skip:39  time:461s
fi-cfl-8700k     total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:390s
fi-cfl-s2        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:572s
fi-cfl-u         total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:492s
fi-cnl-y3        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:573s
fi-elk-e7500     total:288  pass:229  dwarn:0   dfail:0   fail:0   skip:59  time:407s
fi-gdg-551       total:288  pass:179  dwarn:0   dfail:0   fail:1   skip:108 time:287s
fi-glk-1         total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:507s
fi-hsw-4770      total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:392s
fi-ilk-650       total:288  pass:228  dwarn:0   dfail:0   fail:0   skip:60  time:404s
fi-ivb-3520m     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:459s
fi-ivb-3770      total:288  pass:255  dwarn:0   dfail:0   fail:0   skip:33  time:410s
fi-kbl-7500u     total:288  pass:263  dwarn:1   dfail:0   fail:0   skip:24  time:450s
fi-kbl-7560u     total:288  pass:269  dwarn:0   dfail:0   fail:0   skip:19  time:485s
fi-kbl-7567u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:448s
fi-kbl-r         total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:494s
fi-pnv-d510      total:288  pass:222  dwarn:1   dfail:0   fail:0   skip:65  time:578s
fi-skl-6260u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:426s
fi-skl-6600u     total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:499s
fi-skl-6700hq    total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:517s
fi-skl-6700k2    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:483s
fi-skl-6770hq    total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:469s
fi-skl-guc       total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:408s
fi-skl-gvtdvm    total:288  pass:265  dwarn:0   dfail:0   fail:0   skip:23  time:428s
fi-snb-2520m     total:245  pass:211  dwarn:0   dfail:0   fail:0   skip:33 
fi-snb-2600      total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:390s

7075ab436b3bb8b97dfde3eb16b2545398938f83 drm-tip: 2018y-03m-02d-13h-04m-00s UTC integration manifest 6b313f784de6 drm: Add BT.2020 constant luminance enum value for the COLOR_ENCODING property c0ec45ad9801 drm: Check property/enum name length
7de598d791f9 drm: Don't create properties without names

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8214/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#8 lore raw

✓ Fi.CI.BAT: success for series starting with [1/3] drm: Don't create properties without names (rev2)

In reply to Ville Syrjala
== Series Details ==

== Series Details ==

Series: series starting with [1/3] drm: Don't create properties without names (rev2)
URL : https://patchwork.freedesktop.org/series/39277/
State : success

== Summary ==

Series 39277v2 series starting with [1/3] drm: Don't create properties without names
https://patchwork.freedesktop.org/api/1.0/series/39277/revisions/2/mbox/

---- Known issues:

Test kms_pipe_crc_basic:

        Subgroup suspend-read-crc-pipe-b:
                pass       -> DMESG-WARN (fi-skl-6700k2) fdo#104108
Test prime_vgem:
        Subgroup basic-fence-flip:
                pass       -> FAIL       (fi-ilk-650) fdo#104008

fdo#104108 https://bugs.freedesktop.org/show_bug.cgi?id=104108
fdo#104008 https://bugs.freedesktop.org/show_bug.cgi?id=104008

fi-bdw-5557u     total:288  pass:267  dwarn:0   dfail:0   fail:0   skip:21  time:417s
fi-bdw-gvtdvm    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:423s
fi-blb-e6850     total:288  pass:223  dwarn:1   dfail:0   fail:0   skip:64  time:376s
fi-bsw-n3050     total:288  pass:242  dwarn:0   dfail:0   fail:0   skip:46  time:478s
fi-bwr-2160      total:288  pass:183  dwarn:0   dfail:0   fail:0   skip:105 time:277s
fi-bxt-j4205     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:480s
fi-byt-j1900     total:288  pass:253  dwarn:0   dfail:0   fail:0   skip:35  time:466s
fi-byt-n2820     total:288  pass:249  dwarn:0   dfail:0   fail:0   skip:39  time:456s
fi-cfl-8700k     total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:395s
fi-cfl-s2        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:569s
fi-cfl-u         total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:488s
fi-elk-e7500     total:288  pass:229  dwarn:0   dfail:0   fail:0   skip:59  time:413s
fi-gdg-551       total:288  pass:179  dwarn:0   dfail:0   fail:1   skip:108 time:289s
fi-glk-1         total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:504s
fi-hsw-4770      total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:386s
fi-ilk-650       total:288  pass:227  dwarn:0   dfail:0   fail:1   skip:60  time:407s
fi-ivb-3520m     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:442s
fi-ivb-3770      total:288  pass:255  dwarn:0   dfail:0   fail:0   skip:33  time:409s
fi-kbl-7500u     total:288  pass:263  dwarn:1   dfail:0   fail:0   skip:24  time:450s
fi-kbl-7560u     total:288  pass:269  dwarn:0   dfail:0   fail:0   skip:19  time:490s
fi-kbl-7567u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:448s
fi-kbl-r         total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:491s
fi-pnv-d510      total:288  pass:222  dwarn:1   dfail:0   fail:0   skip:65  time:578s
fi-skl-6260u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:426s
fi-skl-6600u     total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:498s
fi-skl-6700hq    total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:517s
fi-skl-6700k2    total:288  pass:263  dwarn:1   dfail:0   fail:0   skip:24  time:486s
fi-skl-6770hq    total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:465s
fi-skl-guc       total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:403s
fi-skl-gvtdvm    total:288  pass:265  dwarn:0   dfail:0   fail:0   skip:23  time:424s
fi-snb-2520m     total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:523s
fi-snb-2600      total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:392s

7075ab436b3bb8b97dfde3eb16b2545398938f83 drm-tip: 2018y-03m-02d-13h-04m-00s UTC integration manifest 0170b5d10306 drm: Add BT.2020 constant luminance enum value for the COLOR_ENCODING property e643d887905b [PATCH v2 2/3 drm: Check property/enum name length
7a28ad7d5e5c drm: Don't create properties without names

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8216/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#9 lore raw

✓ Fi.CI.IGT: success for series starting with [1/3] drm: Don't create properties without names (rev2)

In reply to Ville Syrjala
== Series Details ==

== Series Details ==

Series: series starting with [1/3] drm: Don't create properties without names (rev2)
URL : https://patchwork.freedesktop.org/series/39277/
State : success

== Summary ==

---- Known issues:

Test kms_chv_cursor_fail:

        Subgroup pipe-b-256x256-bottom-edge:
                pass       -> DMESG-WARN (shard-snb) fdo#105185 +2
Test kms_flip:
        Subgroup 2x-flip-vs-expired-vblank:
                pass       -> FAIL       (shard-hsw) fdo#102887
        Subgroup plain-flip-fb-recreate-interruptible:
                pass       -> FAIL       (shard-hsw) fdo#100368

fdo#105185 https://bugs.freedesktop.org/show_bug.cgi?id=105185
fdo#102887 https://bugs.freedesktop.org/show_bug.cgi?id=102887
fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368

shard-apl        total:3463 pass:1823 dwarn:1   dfail:0   fail:7   skip:1632 time:12511s
shard-hsw        total:3463 pass:1768 dwarn:1   dfail:0   fail:3   skip:1690 time:12054s
shard-snb        total:3463 pass:1360 dwarn:3   dfail:0   fail:1   skip:2099 time:6997s

Blacklisted hosts:
shard-kbl total:3401 pass:1906 dwarn:1 dfail:0 fail:7 skip:1485 time:9036s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8216/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reviewed-by on v1 1/3
#10 lore raw
In reply to Ville Syrjala
Quoted 6 lines · Ville Syrjala

From: Ville Syrjälä <[email protected]>

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

Quoted 28 lines
---
 drivers/gpu/drm/drm_property.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_property.c +2 -4
index bae50e6b819d..fe8627fb7ae6 100644
@@ -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);
 
Signature · 6 lines
2.13.6

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#11 lore raw
In reply to Ville Syrjala

Hi Ville,

Quoted 15 lines · Ville Syrjala

From: Ville Syrjälä <[email protected]>

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

---
 drivers/gpu/drm/drm_property.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_property.c +0 -0
index bae50e6b819d..fe8627fb7ae6 100644

drivers/gpu/drm/drm_property.c struct drm_property *drm_property_create(struct drm_device *dev, int flags, · line 104

Quoted 10 lines
drivers/gpu/drm/drm_property.c +2 -4
@@ -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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#12 lore raw
Quoted 21 lines · Emil Velikov

Hi Ville,

Quoted 18 lines · Ville Syrjala

From: Ville Syrjälä <[email protected]>

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

---
 drivers/gpu/drm/drm_property.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_property.c +0 -0
index bae50e6b819d..fe8627fb7ae6 100644
@@ -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);
 
Quoted 9 lines

drivers/gpu/drm/drm_property.c struct drm_property *drm_property_create(struct drm_device *dev, int flags, · line 104

Quoted 7 lines
drivers/gpu/drm/drm_property.c +2 -4
-       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?

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#13 lore raw
Quoted 32 lines · Ville Syrjälä
Quoted 21 lines · Emil Velikov

Hi Ville,

Quoted 18 lines · Ville Syrjala

From: Ville Syrjälä <[email protected]>

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

---
 drivers/gpu/drm/drm_property.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_property.c +0 -0
index bae50e6b819d..fe8627fb7ae6 100644
@@ -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);
 
Quoted 9 lines

drivers/gpu/drm/drm_property.c struct drm_property *drm_property_create(struct drm_device *dev, int flags, · line 104

Quoted 7 lines
drivers/gpu/drm/drm_property.c +2 -4
-       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?

Quoted 2 lines

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 ;-)

Quoted 2 lines

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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx