Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] drm/bridge: inno-hdmi: null pointer dereference in
  inno_hdmi_i2c_xfer() [1]
--

commit 95253be01dd44552656110fd639d49c16e43c337
Author: Michal Wilczynski <[email protected]>

drm/bridge: inno-hdmi: Report hotplug through drm_bridge_hpd_notify()

This commit changes inno_hdmi_irq() to report hotplug events through
drm_bridge_hpd_notify() and moves devm_request_threaded_irq() in
inno_hdmi_bind() after devm_drm_bridge_add().

> diff --git a/drivers/gpu/drm/bridge/inno-hdmi.c 
> b/drivers/gpu/drm/bridge/inno-hdmi.c
> index 3bdcacf3cbc84..bbc90ae9eaae0 100644
> --- a/drivers/gpu/drm/bridge/inno-hdmi.c
> +++ b/drivers/gpu/drm/bridge/inno-hdmi.c

[ ... ]

> @@ -1129,6 +1124,16 @@ struct inno_hdmi *inno_hdmi_bind(struct device *dev,
>       if (ret)
>               return ERR_PTR(ret);
>  
> +     /*
> +      * The hotplug handler takes the bridge's HPD mutex, which
> +      * drm_bridge_add() initialises, so request the interrupt only now.
> +      */
> +     ret = devm_request_threaded_irq(dev, irq, inno_hdmi_hardirq,
> +                                     inno_hdmi_irq, IRQF_SHARED,
> +                                     dev_name(dev), hdmi);
> +     if (ret)
> +             return ERR_PTR(ret);
> +
>       ret = drm_bridge_attach(encoder, &hdmi->bridge, NULL, 
> DRM_BRIDGE_ATTACH_NO_CONNECTOR);
>       if (ret)
>               return ERR_PTR(ret);

[Severity: High]
This problem wasn't introduced by this patch, but can
inno_hdmi_i2c_adapter() race with a concurrent I2C transfer and cause a
NULL pointer dereference in inno_hdmi_i2c_xfer() [1]?

Just before devm_drm_bridge_add(), inno_hdmi_bind() calls
inno_hdmi_i2c_adapter(), which publishes the adapter via
devm_i2c_add_adapter() before assigning hdmi->i2c:

CPU0                              CPU1
inno_hdmi_i2c_adapter()
  i2c_set_adapdata(adap, hdmi)
  devm_i2c_add_adapter(..., adap)
                                  inno_hdmi_i2c_xfer()
                                    hdmi = i2c_get_adapdata(adap)
                                    i2c = hdmi->i2c  <-- NULL
                                    mutex_lock(&i2c->lock)
  hdmi->i2c = i2c

If a transfer starts right after devm_i2c_add_adapter() registers the
adapter, inno_hdmi_i2c_xfer() reads a NULL hdmi->i2c and dereferences it
in mutex_lock(&i2c->lock).

[1] https://sashiko.dev/#/bug/linux-c25575e8-f25c-439d-83ee-81502085106c

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=2

Reply via email to