Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] drm/vkms: plane_supported_color_ranges_store() rejects 0 bitmask - [Medium] drm/vkms: plane_default_color_range_store() rejects hex bitmasks via base 10 - [Low] drm/vkms: type mismatch in plane_default_color_range_store() kstrtouint() call --
commit 43491ccf15c9b0119d0720030c6887bb6debdc75 Author: Louis Chauvet <[email protected]> drm/vkms: Introduce configfs for plane color range This commit adds supported_color_ranges and default_color_range configfs attributes for VKMS planes and documents them. > diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c > b/drivers/gpu/drm/vkms/vkms_configfs.c > index c6efc6db64c46..a746fb5e22a37 100644 > --- a/drivers/gpu/drm/vkms/vkms_configfs.c > +++ b/drivers/gpu/drm/vkms/vkms_configfs.c [ ... ] > @@ -410,6 +417,86 @@ static ssize_t plane_default_rotation_store(struct > config_item *item, > return count; > } > > +static ssize_t plane_supported_color_ranges_show(struct config_item *item, > char *page) > +{ > + struct vkms_configfs_plane *plane = > plane_item_to_vkms_configfs_plane(item); > + unsigned int supported_color_ranges; > + > + scoped_guard(mutex, &plane->dev->config->lock) > + supported_color_ranges = > vkms_config_plane_get_supported_color_ranges(plane->config); > + > + return sprintf(page, "%u\n", supported_color_ranges); > +} > + > +static ssize_t plane_supported_color_ranges_store(struct config_item *item, > + const char *page, size_t > count) > +{ > + struct vkms_configfs_plane *plane = > plane_item_to_vkms_configfs_plane(item); > + int ret; > + unsigned int val = 0; > + > + ret = kstrtouint(page, 0, &val); > + if (ret) > + return ret; > + > + /* Should be a supported value */ > + if (val & ~VKMS_SUPPORTED_COLOR_RANGES) > + return -EINVAL; > + /* Should at least provide one color range */ > + if ((val & VKMS_SUPPORTED_COLOR_RANGES) == 0) > + return -EINVAL; [Severity: Medium] Should plane_supported_color_ranges_store() allow writing 0 to disable the COLOR_RANGE property? vkms_config_create_plane() initializes supported_color_ranges to a non-zero mask, and vkms_config_is_valid() requires supported_color_encodings and supported_color_ranges to either both be set or both be 0: drivers/gpu/drm/vkms/vkms_config.c:vkms_config_is_valid() { ... if ((vkms_config_plane_get_supported_color_encodings(plane_cfg) == 0) != (vkms_config_plane_get_supported_color_ranges(plane_cfg) == 0)) { drm_info(dev, "Both supported color encodings and color ranges must be set, or none\n"); return false; } ... } While plane_supported_color_encodings_store() allows writing 0, rejecting 0 here prevents userspace from disabling YCbCr color properties on a plane via configfs, and setting supported_color_encodings to 0 leaves the device configuration invalid. [ ... ] > +static ssize_t plane_default_color_range_store(struct config_item *item, > + const char *page, size_t count) > +{ > + struct vkms_configfs_plane *plane = > plane_item_to_vkms_configfs_plane(item); > + int ret, val = 0; [Severity: Low] This isn't a runtime bug because (val & ~VKMS_SUPPORTED_COLOR_RANGES) rejects negative values, but val is declared as a signed int while kstrtouint() takes an unsigned int *, triggering a -Wpointer-sign mismatch. > + > + ret = kstrtouint(page, 10, &val); [Severity: Medium] Should kstrtouint() use base 0 instead of base 10 here? Documentation/gpu/vkms.rst states that default_color_range accepts the same values as supported_color_ranges (documented as 0x1 and 0x2), and the other bitmask store callbacks such as plane_default_color_encoding_store() use base 0. Passing base 10 causes hexadecimal inputs like 0x1 or 0x2 to fail with -EINVAL. -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=24
