Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] drm/connector: dynamic HDMI init creates non-refcounted drm_property post-reg --
commit 3a8f2d8e52f1964bd9a6d73f9170a7532ea70354 Author: Luca Ceresoli <[email protected]> drm/connector: add drm_connector_hdmi_dynamic_init() This commit adds drm_connector_hdmi_dynamic_init() to initialize dynamically created HDMI connectors for hotpluggable bridges. > diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c > index 20120b6a05d52..021f2e120fdc7 100644 > --- a/drivers/gpu/drm/drm_connector.c > +++ b/drivers/gpu/drm/drm_connector.c > @@ -704,6 +704,49 @@ int drmm_connector_hdmi_init(struct drm_device *dev, > } > EXPORT_SYMBOL(drmm_connector_hdmi_init); > > +/** > + * drm_connector_hdmi_dynamic_init - Init a preallocated dynamic HDMI > connector > + * @dev: DRM device > + * @connector: A pointer to the HDMI connector to init > + * @funcs: callbacks for this connector > + * @hdmi_funcs: HDMI-related callbacks and capabilities for this connector > + * @connector_type: user visible type of the connector > + * @ddc: optional pointer to the associated ddc adapter > + * > + * Initialises a preallocated dynamic HDMI connector. Connectors can be > + * subclassed as part of driver connector objects. > + * > + * See drm_connector_dynamic_init(), the same constraints apply here. This > + * is just the HDMI version. > + * > + * Returns: > + * Zero on success, error code on failure. > + */ > +int drm_connector_hdmi_dynamic_init(struct drm_device *dev, > + struct drm_connector *connector, > + const struct drm_connector_funcs *funcs, > + const struct drm_connector_hdmi_funcs > *hdmi_funcs, > + int connector_type, > + struct i2c_adapter *ddc) > +{ > + int ret; > + > + ret = drm_connector_hdmi_sanity_checks(dev, connector, hdmi_funcs, > connector_type); > + if (ret) > + return ret; > + > + ret = drm_connector_dynamic_init(dev, connector, funcs, connector_type, > ddc); > + if (ret) > + return ret; > + > + ret = drm_connector_hdmi_initialize(dev, connector, hdmi_funcs); > + if (ret) > + drm_connector_cleanup(connector); > + > + return ret; > +} > +EXPORT_SYMBOL(drm_connector_hdmi_dynamic_init); [Severity: High] Can drm_connector_hdmi_initialize() be called safely after drm_dev_register() has registered the DRM device? On a fresh connector, drm_connector_hdmi_initialize() calls drm_connector_attach_max_bpc_property() and drm_connector_attach_color_format_property(), which create new drm_property objects via drm_property_create_range() and drm_property_create_enum(). Because DRM properties are non-refcounted mode objects (obj_free_cb is NULL), calling drm_property_create() -> drm_mode_object_add() when dev->registered is true triggers: drivers/gpu/drm/drm_mode_object.c:__drm_mode_object_add() { WARN_ON(!dev->driver->load && dev->registered && !obj_free_cb); } In addition, drm_property_create() adds the property to dev->mode_config.property_list without locking and publishes it in dev->mode_config.object_idr before initializing its fields and enum_list, allowing a concurrent drm_mode_getproperty_ioctl() to observe an uninitialized property. Finally, drm_connector_cleanup() does not destroy connector->max_bpc_property or connector->color_format_property, so those properties and their mode object IDs are leaked if drm_connector_attach_color_format_property() fails or each time an HDMI connector is hot-unplugged and re-plugged. -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=6
