Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] drm/panel: missing put_device() causes refcount leak in panel_dbi_prepare() - [High] drm/panel: unsafe lockless access to remote drvdata risks UAF --
commit af85d3c58c7325c679bd0289254561bdca27049a Author: Svyatoslav Ryhel <[email protected]> drm/panel: Add Hitachi TX10D07VM0BAA and LG LH400WV3-SD04 MIPI DBI panel driver This commit adds a DRM panel driver for the Hitachi TX10D07VM0BAA and LG LH400WV3-SD04 MIPI DBI panels used in the LG Optimus 2X P990. These panels are linked to the DRM encoder via an RGB to DBI bridge. > diff --git a/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c > b/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c > new file mode 100644 > index 0000000000000..e78814c9697af > --- /dev/null > +++ b/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c [ ... ] > +static int panel_dbi_prepare(struct drm_panel *panel) > +{ > + struct panel_dbi *priv = to_panel_dbi(panel); > + struct platform_device *bridge_pdev; > + struct device_node *bridge_node; > + struct device *dev = panel->dev; > + int ret; > + > + bridge_node = of_graph_get_remote_node(dev_of_node(dev), 0, 0); > + if (!bridge_node) > + return -ENODEV; > + > + bridge_pdev = of_find_device_by_node(bridge_node); > + of_node_put(bridge_node); > + if (!bridge_pdev) > + return -ENODEV; [Severity: High] Does this code leak the reference to bridge_pdev? The function of_find_device_by_node() increments the reference count of the returned platform device, but it doesn't appear to be released with put_device() anywhere in this function. Since panel_dbi_prepare() is called on every display enable operation (such as during a DPMS on/off cycle), couldn't this leak references incrementally and eventually lead to a refcount overflow or memory exhaustion? > + > + priv->dbi = platform_get_drvdata(bridge_pdev); [Severity: High] Is it safe to cache the remote bridge device's drvdata locklessly here? If the bridge device gets unbound via sysfs while the panel is still active, the bridge's devres-managed memory would be freed. A subsequent panel operation, such as calling panel_dbi_command() during teardown, would then dereference the freed pointer: ret = mipi_dbi_command_stackbuf((priv)->dbi, cmd, d, ARRAY_SIZE(d)); Could this lead to a use-after-free, since there is no device link or locking holding a reference to the bridge's lifecycle? > + if (!priv->dbi) > + return -ENODEV; > + > + gpiod_set_value_cansleep(priv->reset_gpio, 1); [ ... ] -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=6
