Thank you for your contribution! Sashiko AI review found 5 potential issues to consider: - [Medium] drm/bridge: trilinear: dptx_deinit() races with dptx_bridge_attach() - [Medium] drm/bridge: trilinear: unlocked device_link_del() races with purge - [Low] drm/cix: MAINTAINERS omits drivers/gpu/drm/cix/ Kconfig and Makefile - [Low] drm/bridge: trilinear: 32-bit overflow in dptx_hw_stream_timing_set() - [Low] drm/cix: rely on undocumented dev_set_drvdata() in trilinear_dptx_probe() --
commit dc89c829eff9a7f0dba586da4c0b1ecdf3d742f9 Author: Luo Liu <[email protected]> drm/cix: add the Sky1 DisplayPort platform glue This commit adds the Cix Sky1 DisplayPort platform glue driver, which maps the SoC RCSU video adapter registers, configures pixel format and pixel-per-clock settings, and binds the shared Trilinear DPTX bridge driver. > diff --git a/MAINTAINERS b/MAINTAINERS > index 9315302ab7628..2314af4da0b7a 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -6535,6 +6535,7 @@ L: [email protected] > S: Maintained > F: Documentation/devicetree/bindings/display/cix,sky1-dp.yaml > F: drivers/gpu/drm/bridge/trilinear/ > +F: drivers/gpu/drm/cix/dptx/ > F: include/drm/bridge/trilinear_dp.h [Severity: Low] Should this entry also cover drivers/gpu/drm/cix/Kconfig and drivers/gpu/drm/cix/Makefile (for example via F: drivers/gpu/drm/cix/)? Those two newly added files are not matched by any MAINTAINERS entry. [ ... ] > diff --git a/drivers/gpu/drm/cix/dptx/cix_dptx.c > b/drivers/gpu/drm/cix/dptx/cix_dptx.c > new file mode 100644 > index 0000000000000..a4e028181383a > --- /dev/null > +++ b/drivers/gpu/drm/cix/dptx/cix_dptx.c [ ... ] > + dp = trilinear_dptx_probe(dev, soc_data, priv); > + if (IS_ERR(dp)) > + return PTR_ERR(dp); > + > + return 0; > +} [Severity: Low] Should cix_dptx_probe() call platform_set_drvdata(pdev, dp) instead of discarding dp? cix_dptx_remove(), cix_dptx_pm_suspend(), cix_dptx_pm_resume(), and cix_dptx_shutdown() all retrieve the struct dptx_dev pointer from drvdata. This currently works only because trilinear_dptx_probe() calls dev_set_drvdata(dev, dp) internally, even though the trilinear driver never reads drvdata and include/drm/bridge/trilinear_dp.h does not document that side effect. Setting drvdata here and dropping dev_set_drvdata() from trilinear_dptx_probe() would match other shared DRM bridge libraries and avoid clobbering drvdata for future glue drivers. > + > +static void cix_dptx_remove(struct platform_device *pdev) > +{ > + trilinear_dptx_remove(platform_get_drvdata(pdev)); > +} [Severity: Medium] Can dptx_deinit() race with dptx_bridge_attach() and leave dp->hpd_event_work polling dp->phy after devres releases it? In drivers/gpu/drm/bridge/trilinear/dptx_core.c, dptx_deinit() sets dp->hpd_stopped = true and drops dp->lock to call dptx_cancel_hpd_works(), setting dp->released = true only in a second dp->lock critical section: CPU0 CPU1 cix_dptx_remove() dptx_deinit() lock(&dp->lock) dp->hpd_stopped = true unlock(&dp->lock) dptx_cancel_hpd_works() dptx_bridge_attach() lock(&dp->lock) /* dp->released is still false */ dp->hpd_stopped = false unlock(&dp->lock) dptx_replay_deferred_hotplug() queue_delayed_work(hpd_event_work) dptx_hpd_event_work_func() /* passes abort check, unlocks */ dptx_wait_phy_dp_mode() lock(&dp->lock) dp->released = true unlock(&dp->lock) devres_release_all() devm_phy_release(dp->phy) phy_get_mode(dp->phy) <-- use-after-free Because dp->hpd_stopped was cleared back to false and dptx_hpd_notify() only checks dp->hpd_stopped (not dp->released), out-of-band HPD notifications on cix,sky1-usbdp can also keep queueing HPD work after device removal. Setting dp->released = true alongside dp->hpd_stopped = true in the first dp->lock critical section of dptx_deinit() closes this window. [Severity: Medium] Can dropping dp->lock before device_link_del() in dptx_deinit() and dptx_bridge_detach() race with device_links_purge()? Both dptx_deinit() and dptx_bridge_detach() clear dp->link under dp->lock, then drop dp->lock before calling device_link_del(link): CPU0 CPU1 dptx_bridge_detach() lock(&dp->lock) link = dp->link dp->link = NULL unlock(&dp->lock) device_del(dp->dev) bus_remove_device() cix_dptx_remove() -> dptx_deinit() /* sees dp->link == NULL */ device_links_purge(dp->dev) __device_link_del(&link->kref) device_link_del(link) <-- double delete / use-after-free The symmetric race happens when dptx_deinit() steals dp->link and drops dp->lock while the consumer device is being deleted. Calling device_link_del(link) while still holding dp->lock (matching device_link_add() in dptx_bridge_attach()) serializes deletion before device_links_purge() can run. [ ... ] > +static const struct dptx_plat_data sky1_usbdp_data = { > + .adapter_config = cix_dp_usbc_adapter_config, > + .oob_hpd = true, > + .max_bw_code = DP_LINK_BW_5_4, > +}; > + > +static const struct dptx_plat_data sky1_dp_data = { > + .adapter_config = cix_dp_native_adapter_config, > + .max_bw_code = DP_LINK_BW_5_4, > +}; [Severity: Low] Can setting max_bw_code to DP_LINK_BW_5_4 trigger a 32-bit overflow in dptx_hw_stream_timing_set()? drivers/gpu/drm/bridge/trilinear/dptx_hw.c:dptx_hw_stream_timing_set() { ... dptx_hw_write(hw, DPTX_SECONDARY_DATA_WINDOW(stream_id), (mode->htotal - mode->hdisplay) * (link_rate / 40) * 9 / mode->clock); ... } Because link_rate is u32, this multiplication is evaluated in 32-bit unsigned arithmetic. At 540000 kHz, (link_rate / 40) * 9 is 121500, so any custom mode with horizontal blanking (mode->htotal - mode->hdisplay) of at least 35350 overflows U32_MAX before dividing by mode->clock. Neither dptx_adjust_mode() nor dptx_bridge_atomic_check() bounds horizontal blanking, so this writes a miscalculated secondary data window to hardware. Computing the numerator in 64-bit arithmetic with div_u64() avoids the wraparound. -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=5
