Skip to contentSkip to conversation

drm/meson: Fix refcount leak in meson_encoder_hdmi_init

PATCH In review Miaoqian Lin 2 participants 3 messages May 12, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/meson: Fix refcount leak in meson_encoder_hdmi_init

of_find_device_by_node() takes a reference to the embedded struct device, we should use put_device() to release it when not need anymore. Add missing put_device() in error path to avoid refcount leak.

Fixes 0af5e0b41110 ("drm/meson: encoder_hdmi: switch to bridge DRM_BRIDGE_ATTACH_NO_CONNECTOR")
---
 drivers/gpu/drm/meson/meson_encoder_hdmi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/meson/meson_encoder_hdmi.c +3 -1
index 5e306de6f485..de87f02cd388 100644
@@ -435,8 +435,10 @@ int meson_encoder_hdmi_init(struct meson_drm *priv)
 		cec_fill_conn_info_from_drm(&conn_info, meson_encoder_hdmi->connector);
 
 		notifier = cec_notifier_conn_register(&pdev->dev, NULL, &conn_info);
-		if (!notifier)
+		if (!notifier) {
+			put_device(&pdev->dev);
 			return -ENOMEM;
+		}
 
 		meson_encoder_hdmi->cec_notifier = notifier;
 	}
Signature · 1 line
2.25.1
#1 lore raw

Hi,

Quoted 6 lines · Miaoqian Lin

of_find_device_by_node() takes a reference to the embedded struct device, we should use put_device() to release it when not need anymore. Add missing put_device() in error path to avoid refcount leak.

Fixes 0af5e0b41110 ("drm/meson: encoder_hdmi: switch to bridge DRM_BRIDGE_ATTACH_NO_CONNECTOR")

You already sent the same patch yesterday, please avoid this.

Neil

Quoted 20 lines
---
  drivers/gpu/drm/meson/meson_encoder_hdmi.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/meson/meson_encoder_hdmi.c +3 -1
index 5e306de6f485..de87f02cd388 100644
@@ -435,8 +435,10 @@ int meson_encoder_hdmi_init(struct meson_drm *priv)
  		cec_fill_conn_info_from_drm(&conn_info, meson_encoder_hdmi->connector);
 
  		notifier = cec_notifier_conn_register(&pdev->dev, NULL, &conn_info);
-		if (!notifier)
+		if (!notifier) {
+			put_device(&pdev->dev);
  			return -ENOMEM;
+		}
 
  		meson_encoder_hdmi->cec_notifier = notifier;
  	}
#2 lore raw

Hi,

Quoted 12 lines · Neil Armstrong

Hi,

Quoted 6 lines · Miaoqian Lin

of_find_device_by_node() takes a reference to the embedded struct device, we should use put_device() to release it when not need anymore. Add missing put_device() in error path to avoid refcount leak.

Fixes 0af5e0b41110 ("drm/meson: encoder_hdmi: switch to bridge DRM_BRIDGE_ATTACH_NO_CONNECTOR")

You already sent the same patch yesterday, please avoid this.

Sorry for the mistake, I realized this after I sent it. I will be more careful.

Quoted 21 lines

Neil

Quoted 18 lines

---
  drivers/gpu/drm/meson/meson_encoder_hdmi.c | 4 +++-

  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/meson/meson_encoder_hdmi.c +3 -1
index 5e306de6f485..de87f02cd388 100644
@@ -435,8 +435,10 @@ int meson_encoder_hdmi_init(struct meson_drm *priv)
           cec_fill_conn_info_from_drm(&conn_info, meson_encoder_hdmi->connector);
             notifier = cec_notifier_conn_register(&pdev->dev, NULL, &conn_info);
-        if (!notifier)
+        if (!notifier) {
+            put_device(&pdev->dev);
               return -ENOMEM;
+        }
             meson_encoder_hdmi->cec_notifier = notifier;
       }