* [PATCH] drm:bridge:analogix: Fix refcount bugs in anx7625_parse_dt()
@ 2022-07-07 1:23 Liang He
2022-07-18 11:54 ` Robert Foss
0 siblings, 1 reply; 7+ messages in thread
From: Liang He @ 2022-07-07 1:23 UTC (permalink / raw)
To: andrzej.hajda, narmstrong, robert.foss, Laurent.pinchart, jonas,
airlied, daniel, dri-devel, windhl
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")
Signed-off-by: Liang He <windhl@126.com>
---
drivers/gpu/drm/bridge/analogix/anx7625.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 53a5da6c49dd..f39b9be19eaf 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -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) */
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] drm:bridge:analogix: Fix refcount bugs in anx7625_parse_dt()
2022-07-07 1:23 [PATCH] drm:bridge:analogix: Fix refcount bugs in anx7625_parse_dt() Liang He
@ 2022-07-18 11:54 ` Robert Foss
2022-07-18 11:55 ` Robert Foss
2022-07-18 11:56 ` Liang He
0 siblings, 2 replies; 7+ messages in thread
From: Robert Foss @ 2022-07-18 11:54 UTC (permalink / raw)
To: Liang He
Cc: andrzej.hajda, jonas, airlied, narmstrong, dri-devel,
Laurent.pinchart
Hey Liang,
On Thu, 7 Jul 2022 at 03:25, Liang He <windhl@126.com> wrote:
>
> 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")
> Signed-off-by: Liang He <windhl@126.com>
> ---
> drivers/gpu/drm/bridge/analogix/anx7625.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
> index 53a5da6c49dd..f39b9be19eaf 100644
> --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
> +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> @@ -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) */
> --
> 2.25.1
>
This patch does not apply on drm-misc-next, could you please rebase it
and send a v2?
Rob.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drm:bridge:analogix: Fix refcount bugs in anx7625_parse_dt()
2022-07-18 11:54 ` Robert Foss
@ 2022-07-18 11:55 ` Robert Foss
2022-07-18 11:57 ` Liang He
2022-07-18 11:56 ` Liang He
1 sibling, 1 reply; 7+ messages in thread
From: Robert Foss @ 2022-07-18 11:55 UTC (permalink / raw)
To: Liang He
Cc: andrzej.hajda, jonas, airlied, narmstrong, dri-devel,
Laurent.pinchart
On Mon, 18 Jul 2022 at 13:54, Robert Foss <robert.foss@linaro.org> wrote:
>
> Hey Liang,
>
>
> On Thu, 7 Jul 2022 at 03:25, Liang He <windhl@126.com> wrote:
> >
> > 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")
> > Signed-off-by: Liang He <windhl@126.com>
> > ---
> > drivers/gpu/drm/bridge/analogix/anx7625.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > index 53a5da6c49dd..f39b9be19eaf 100644
> > --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
> > +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > @@ -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) */
> > --
> > 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:"
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re:Re: [PATCH] drm:bridge:analogix: Fix refcount bugs in anx7625_parse_dt()
2022-07-18 11:54 ` Robert Foss
2022-07-18 11:55 ` Robert Foss
@ 2022-07-18 11:56 ` Liang He
2022-07-18 13:35 ` Liang He
1 sibling, 1 reply; 7+ messages in thread
From: Liang He @ 2022-07-18 11:56 UTC (permalink / raw)
To: Robert Foss
Cc: andrzej.hajda, jonas, airlied, narmstrong, dri-devel,
Laurent.pinchart
At 2022-07-18 19:54:18, "Robert Foss" <robert.foss@linaro.org> wrote:
>Hey Liang,
>
>
>On Thu, 7 Jul 2022 at 03:25, Liang He <windhl@126.com> wrote:
>>
>> 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")
>> Signed-off-by: Liang He <windhl@126.com>
>> ---
>> drivers/gpu/drm/bridge/analogix/anx7625.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
>> index 53a5da6c49dd..f39b9be19eaf 100644
>> --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
>> +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
>> @@ -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) */
>> --
>> 2.25.1
>>
>
>This patch does not apply on drm-misc-next, could you please rebase it
>and send a v2?
>
>Rob.
Thanks for your reply.
I will rebase it soon.
Liang
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re:Re: [PATCH] drm:bridge:analogix: Fix refcount bugs in anx7625_parse_dt()
2022-07-18 11:55 ` Robert Foss
@ 2022-07-18 11:57 ` Liang He
0 siblings, 0 replies; 7+ messages in thread
From: Liang He @ 2022-07-18 11:57 UTC (permalink / raw)
To: Robert Foss
Cc: andrzej.hajda, jonas, airlied, narmstrong, dri-devel,
Laurent.pinchart
At 2022-07-18 19:55:16, "Robert Foss" <robert.foss@linaro.org> wrote:
>On Mon, 18 Jul 2022 at 13:54, Robert Foss <robert.foss@linaro.org> wrote:
>>
>> Hey Liang,
>>
>>
>> On Thu, 7 Jul 2022 at 03:25, Liang He <windhl@126.com> wrote:
>> >
>> > 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")
>> > Signed-off-by: Liang He <windhl@126.com>
>> > ---
>> > drivers/gpu/drm/bridge/analogix/anx7625.c | 2 ++
>> > 1 file changed, 2 insertions(+)
>> >
>> > diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
>> > index 53a5da6c49dd..f39b9be19eaf 100644
>> > --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
>> > +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
>> > @@ -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) */
>> > --
>> > 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:"
Thanks, I will fix it in new patch.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re:Re:Re: [PATCH] drm:bridge:analogix: Fix refcount bugs in anx7625_parse_dt()
2022-07-18 11:56 ` Liang He
@ 2022-07-18 13:35 ` Liang He
2022-07-18 15:00 ` Robert Foss
0 siblings, 1 reply; 7+ messages in thread
From: Liang He @ 2022-07-18 13:35 UTC (permalink / raw)
To: Robert Foss
Cc: andrzej.hajda, jonas, airlied, narmstrong, dri-devel,
Laurent.pinchart
At 2022-07-18 19:56:09, "Liang He" <windhl@126.com> wrote:
>
>At 2022-07-18 19:54:18, "Robert Foss" <robert.foss@linaro.org> wrote:
>>Hey Liang,
>>
>>
>>On Thu, 7 Jul 2022 at 03:25, Liang He <windhl@126.com> wrote:
>>>
>>> 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")
>>> Signed-off-by: Liang He <windhl@126.com>
>>> ---
>>> drivers/gpu/drm/bridge/analogix/anx7625.c | 2 ++
>>> 1 file changed, 2 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
>>> index 53a5da6c49dd..f39b9be19eaf 100644
>>> --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
>>> +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
>>> @@ -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) */
>>> --
>>> 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
>>Rob.
>
>Thanks for your reply.
>
>I will rebase it soon.
>
>Liang
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Re:Re: [PATCH] drm:bridge:analogix: Fix refcount bugs in anx7625_parse_dt()
2022-07-18 13:35 ` Liang He
@ 2022-07-18 15:00 ` Robert Foss
0 siblings, 0 replies; 7+ messages in thread
From: Robert Foss @ 2022-07-18 15:00 UTC (permalink / raw)
To: Liang He
Cc: andrzej.hajda, jonas, airlied, narmstrong, dri-devel,
Laurent.pinchart
On Mon, 18 Jul 2022 at 15:35, Liang He <windhl@126.com> wrote:
>
>
> At 2022-07-18 19:56:09, "Liang He" <windhl@126.com> wrote:
> >
> >At 2022-07-18 19:54:18, "Robert Foss" <robert.foss@linaro.org> wrote:
> >>Hey Liang,
> >>
> >>
> >>On Thu, 7 Jul 2022 at 03:25, Liang He <windhl@126.com> wrote:
> >>>
> >>> 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")
> >>> Signed-off-by: Liang He <windhl@126.com>
> >>> ---
> >>> drivers/gpu/drm/bridge/analogix/anx7625.c | 2 ++
> >>> 1 file changed, 2 insertions(+)
> >>>
> >>> diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
> >>> index 53a5da6c49dd..f39b9be19eaf 100644
> >>> --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
> >>> +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> >>> @@ -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) */
> >>> --
> >>> 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 ?
Ideally not, sometimes this will cause issues where I can't pull your patches.
> 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
>
>
> Thanks a lot,
>
>
> Liang
>
> >>Rob.
> >
> >Thanks for your reply.
> >
> >I will rebase it soon.
> >
> >Liang
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-07-18 15:00 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-07 1:23 [PATCH] drm:bridge:analogix: Fix refcount bugs in anx7625_parse_dt() Liang He
2022-07-18 11:54 ` Robert Foss
2022-07-18 11:55 ` Robert Foss
2022-07-18 11:57 ` Liang He
2022-07-18 11:56 ` Liang He
2022-07-18 13:35 ` Liang He
2022-07-18 15:00 ` Robert Foss
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.