Skip to contentSkip to conversation

drm:bridge:analogix: Fix refcount bugs in anx7625_parse_dt()

PATCH Superseded Liang He 2 participants 7 messages Jul 7, 2022 – Jul 18, 2022

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH 1/1 drm:bridge:analogix: Fix refcount bugs in anx7625_parse_dt()

There are two refcount bugs in this funcion:

BUG-1: 'pdata->mipi_host_node' will be assigned a new reference with of_graph_get_remote_node() which will increase the refcount of the object, correspondingly, we should call of_node_put() for the old reference stored in the 'pdata->mipi_host_node'.

BUG-2: of_graph_get_endpoint_by_regs() will also increase the refcount of the object and its new reference will be assigned to local 'ep0', so there should be a of_node_put() when 'ep0' is not used anymore.

Fixes 8bdfc5dae4e3 ("drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP")
Fixes fd0310b6fe7d ("drm/bridge: anx7625: add MIPI DPI input feature")
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/bridge/analogix/anx7625.c +2 -0
index 53a5da6c49dd..f39b9be19eaf 100644
@@ -1624,6 +1624,7 @@ static int anx7625_parse_dt(struct device *dev,
 	anx7625_get_swing_setting(dev, pdata);
 
 	pdata->is_dpi = 1; /* default dpi mode */
+	of_node_put(pdata->mipi_host_node);
 	pdata->mipi_host_node = of_graph_get_remote_node(np, 0, 0);
 	if (!pdata->mipi_host_node) {
 		DRM_DEV_ERROR(dev, "fail to get internal panel.\n");
@@ -1638,6 +1639,7 @@ static int anx7625_parse_dt(struct device *dev,
 			bus_type = 0;
 
 		mipi_lanes = of_property_count_u32_elems(ep0, "data-lanes");
+		of_node_put(ep0);
 	}
 
 	if (bus_type == V4L2_FWNODE_BUS_TYPE_PARALLEL) /* bus type is Parallel(DSI) */
Signature · 1 line
2.25.1
#1 lore raw

Hey Liang,

Quoted 40 lines · Liang He

There are two refcount bugs in this funcion:

BUG-1: 'pdata->mipi_host_node' will be assigned a new reference with of_graph_get_remote_node() which will increase the refcount of the object, correspondingly, we should call of_node_put() for the old reference stored in the 'pdata->mipi_host_node'.

BUG-2: of_graph_get_endpoint_by_regs() will also increase the refcount of the object and its new reference will be assigned to local 'ep0', so there should be a of_node_put() when 'ep0' is not used anymore.

Fixes 8bdfc5dae4e3 ("drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP")
Fixes fd0310b6fe7d ("drm/bridge: anx7625: add MIPI DPI input feature")
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/bridge/analogix/anx7625.c +2 -1
index 53a5da6c49dd..f39b9be19eaf 100644
@@ -1624,6 +1624,7 @@ static int anx7625_parse_dt(struct device *dev,
        anx7625_get_swing_setting(dev, pdata);
 
        pdata->is_dpi = 1; /* default dpi mode */
+       of_node_put(pdata->mipi_host_node);
        pdata->mipi_host_node = of_graph_get_remote_node(np, 0, 0);
        if (!pdata->mipi_host_node) {
                DRM_DEV_ERROR(dev, "fail to get internal panel.\n");
@@ -1638,6 +1639,7 @@ static int anx7625_parse_dt(struct device *dev,
                        bus_type = 0;
 
                mipi_lanes = of_property_count_u32_elems(ep0, "data-lanes");
+               of_node_put(ep0);
        }
 
        if (bus_type == V4L2_FWNODE_BUS_TYPE_PARALLEL) /* bus type is Parallel(DSI) */
--
Quoted 2 lines

2.25.1

This patch does not apply on drm-misc-next, could you please rebase it and send a v2?

Rob.

#2 lore raw
Quoted 43 lines · Robert Foss

Hey Liang,

Quoted 38 lines · Liang He

There are two refcount bugs in this funcion:

BUG-1: 'pdata->mipi_host_node' will be assigned a new reference with of_graph_get_remote_node() which will increase the refcount of the object, correspondingly, we should call of_node_put() for the old reference stored in the 'pdata->mipi_host_node'.

BUG-2: of_graph_get_endpoint_by_regs() will also increase the refcount of the object and its new reference will be assigned to local 'ep0', so there should be a of_node_put() when 'ep0' is not used anymore.

Fixes 8bdfc5dae4e3 ("drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP")
Fixes fd0310b6fe7d ("drm/bridge: anx7625: add MIPI DPI input feature")
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/bridge/analogix/anx7625.c +2 -0
index 53a5da6c49dd..f39b9be19eaf 100644
@@ -1624,6 +1624,7 @@ static int anx7625_parse_dt(struct device *dev,
        anx7625_get_swing_setting(dev, pdata);
 
        pdata->is_dpi = 1; /* default dpi mode */
+       of_node_put(pdata->mipi_host_node);
        pdata->mipi_host_node = of_graph_get_remote_node(np, 0, 0);
        if (!pdata->mipi_host_node) {
                DRM_DEV_ERROR(dev, "fail to get internal panel.\n");
@@ -1638,6 +1639,7 @@ static int anx7625_parse_dt(struct device *dev,
                        bus_type = 0;
 
                mipi_lanes = of_property_count_u32_elems(ep0, "data-lanes");
+               of_node_put(ep0);
        }
 
Quoted 7 lines
Quoted 4 lines
drivers/gpu/drm/bridge/analogix/anx7625.c +0 -1
        if (bus_type == V4L2_FWNODE_BUS_TYPE_PARALLEL) /* bus type is Parallel(DSI) */
--

2.25.1

This patch does not apply on drm-misc-next, could you please rebase it and send a v2?

Can you also fix the title, it should start with "drm/bridge: anx7625:"

author
#3 lore raw
Quoted 52 lines · Robert Foss
Quoted 43 lines · Robert Foss

Hey Liang,

Quoted 38 lines · Liang He

There are two refcount bugs in this funcion:

BUG-1: 'pdata->mipi_host_node' will be assigned a new reference with of_graph_get_remote_node() which will increase the refcount of the object, correspondingly, we should call of_node_put() for the old reference stored in the 'pdata->mipi_host_node'.

BUG-2: of_graph_get_endpoint_by_regs() will also increase the refcount of the object and its new reference will be assigned to local 'ep0', so there should be a of_node_put() when 'ep0' is not used anymore.

Fixes 8bdfc5dae4e3 ("drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP")
Fixes fd0310b6fe7d ("drm/bridge: anx7625: add MIPI DPI input feature")
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/bridge/analogix/anx7625.c +2 -0
index 53a5da6c49dd..f39b9be19eaf 100644
@@ -1624,6 +1624,7 @@ static int anx7625_parse_dt(struct device *dev,
        anx7625_get_swing_setting(dev, pdata);
 
        pdata->is_dpi = 1; /* default dpi mode */
+       of_node_put(pdata->mipi_host_node);
        pdata->mipi_host_node = of_graph_get_remote_node(np, 0, 0);
        if (!pdata->mipi_host_node) {
                DRM_DEV_ERROR(dev, "fail to get internal panel.\n");
@@ -1638,6 +1639,7 @@ static int anx7625_parse_dt(struct device *dev,
                        bus_type = 0;
 
                mipi_lanes = of_property_count_u32_elems(ep0, "data-lanes");
+               of_node_put(ep0);
        }
 
Quoted 7 lines
Quoted 4 lines
drivers/gpu/drm/bridge/analogix/anx7625.c +0 -1
        if (bus_type == V4L2_FWNODE_BUS_TYPE_PARALLEL) /* bus type is Parallel(DSI) */
--

2.25.1

This patch does not apply on drm-misc-next, could you please rebase it and send a v2?

Quoted 1 line

Can you also fix the title, it should start with "drm/bridge: anx7625:"

Thanks, I will fix it in new patch.

author
#4 lore raw
In reply to Robert Foss
Quoted 50 lines · Robert Foss

Hey Liang,

Quoted 40 lines · Liang He

There are two refcount bugs in this funcion:

BUG-1: 'pdata->mipi_host_node' will be assigned a new reference with of_graph_get_remote_node() which will increase the refcount of the object, correspondingly, we should call of_node_put() for the old reference stored in the 'pdata->mipi_host_node'.

BUG-2: of_graph_get_endpoint_by_regs() will also increase the refcount of the object and its new reference will be assigned to local 'ep0', so there should be a of_node_put() when 'ep0' is not used anymore.

Fixes 8bdfc5dae4e3 ("drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP")
Fixes fd0310b6fe7d ("drm/bridge: anx7625: add MIPI DPI input feature")
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/bridge/analogix/anx7625.c +2 -1
index 53a5da6c49dd..f39b9be19eaf 100644
@@ -1624,6 +1624,7 @@ static int anx7625_parse_dt(struct device *dev,
        anx7625_get_swing_setting(dev, pdata);
 
        pdata->is_dpi = 1; /* default dpi mode */
+       of_node_put(pdata->mipi_host_node);
        pdata->mipi_host_node = of_graph_get_remote_node(np, 0, 0);
        if (!pdata->mipi_host_node) {
                DRM_DEV_ERROR(dev, "fail to get internal panel.\n");
@@ -1638,6 +1639,7 @@ static int anx7625_parse_dt(struct device *dev,
                        bus_type = 0;
 
                mipi_lanes = of_property_count_u32_elems(ep0, "data-lanes");
+               of_node_put(ep0);
        }
 
        if (bus_type == V4L2_FWNODE_BUS_TYPE_PARALLEL) /* bus type is Parallel(DSI) */
--
Quoted 2 lines

2.25.1

This patch does not apply on drm-misc-next, could you please rebase it and send a v2?

Quoted 1 line

Rob.

Thanks for your reply.

I will rebase it soon.

Liang

author
#5 lore raw
Quoted 44 lines · Liang He
Quoted 42 lines · Robert Foss

Hey Liang,

Quoted 38 lines · Liang He

There are two refcount bugs in this funcion:

BUG-1: 'pdata->mipi_host_node' will be assigned a new reference with of_graph_get_remote_node() which will increase the refcount of the object, correspondingly, we should call of_node_put() for the old reference stored in the 'pdata->mipi_host_node'.

BUG-2: of_graph_get_endpoint_by_regs() will also increase the refcount of the object and its new reference will be assigned to local 'ep0', so there should be a of_node_put() when 'ep0' is not used anymore.

Fixes 8bdfc5dae4e3 ("drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP")
Fixes fd0310b6fe7d ("drm/bridge: anx7625: add MIPI DPI input feature")
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/bridge/analogix/anx7625.c +2 -0
index 53a5da6c49dd..f39b9be19eaf 100644
@@ -1624,6 +1624,7 @@ static int anx7625_parse_dt(struct device *dev,
        anx7625_get_swing_setting(dev, pdata);
 
        pdata->is_dpi = 1; /* default dpi mode */
+       of_node_put(pdata->mipi_host_node);
        pdata->mipi_host_node = of_graph_get_remote_node(np, 0, 0);
        if (!pdata->mipi_host_node) {
                DRM_DEV_ERROR(dev, "fail to get internal panel.\n");
@@ -1638,6 +1639,7 @@ static int anx7625_parse_dt(struct device *dev,
                        bus_type = 0;
 
                mipi_lanes = of_property_count_u32_elems(ep0, "data-lanes");
+               of_node_put(ep0);
        }
 
Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
drivers/gpu/drm/bridge/analogix/anx7625.c +0 -1
        if (bus_type == V4L2_FWNODE_BUS_TYPE_PARALLEL) /* bus type is Parallel(DSI) */
--

2.25.1

This patch does not apply on drm-misc-next, could you please rebase it and send a v2?

Hi, Rob, may I rebase it with linux-next/master ?
As I cannot find drm-misc-next, or can you teach me how to rebase that branch?

Thanks a lot,

Liang

Quoted 7 lines
Quoted 1 line

Rob.

Thanks for your reply.

I will rebase it soon.

Liang

#6 lore raw
Quoted 58 lines · Liang He
Quoted 44 lines · Liang He
Quoted 42 lines · Robert Foss

Hey Liang,

Quoted 38 lines · Liang He

There are two refcount bugs in this funcion:

BUG-1: 'pdata->mipi_host_node' will be assigned a new reference with of_graph_get_remote_node() which will increase the refcount of the object, correspondingly, we should call of_node_put() for the old reference stored in the 'pdata->mipi_host_node'.

BUG-2: of_graph_get_endpoint_by_regs() will also increase the refcount of the object and its new reference will be assigned to local 'ep0', so there should be a of_node_put() when 'ep0' is not used anymore.

Fixes 8bdfc5dae4e3 ("drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP")
Fixes fd0310b6fe7d ("drm/bridge: anx7625: add MIPI DPI input feature")
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/bridge/analogix/anx7625.c +2 -0
index 53a5da6c49dd..f39b9be19eaf 100644
@@ -1624,6 +1624,7 @@ static int anx7625_parse_dt(struct device *dev,
        anx7625_get_swing_setting(dev, pdata);
 
        pdata->is_dpi = 1; /* default dpi mode */
+       of_node_put(pdata->mipi_host_node);
        pdata->mipi_host_node = of_graph_get_remote_node(np, 0, 0);
        if (!pdata->mipi_host_node) {
                DRM_DEV_ERROR(dev, "fail to get internal panel.\n");
@@ -1638,6 +1639,7 @@ static int anx7625_parse_dt(struct device *dev,
                        bus_type = 0;
 
                mipi_lanes = of_property_count_u32_elems(ep0, "data-lanes");
+               of_node_put(ep0);
        }
 
Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
drivers/gpu/drm/bridge/analogix/anx7625.c +0 -1
        if (bus_type == V4L2_FWNODE_BUS_TYPE_PARALLEL) /* bus type is Parallel(DSI) */
--

2.25.1

This patch does not apply on drm-misc-next, could you please rebase it and send a v2?

Quoted 1 line

Hi, Rob, may I rebase it with linux-next/master ?

Ideally not, sometimes this will cause issues where I can't pull your patches.

Quoted 1 line

As I cannot find drm-misc-next, or can you teach me how to rebase that branch?

git remote add linux-misc git://anongit.freedesktop.org/drm/drm-misc
git fetch linux-misc
git rebase linux-misc/drm-misc-next

Quoted 14 lines

Thanks a lot,

Liang

Quoted 7 lines
Quoted 1 line

Rob.

Thanks for your reply.

I will rebase it soon.

Liang