* [PATCH] USB: dwc3: add missing of_node_put()
@ 2019-02-03 3:52 wen yang
2019-02-06 8:46 ` Patrice CHOTARD
0 siblings, 1 reply; 3+ messages in thread
From: wen yang @ 2019-02-03 3:52 UTC (permalink / raw)
To: patrice.chotard, balbi, gregkh
Cc: wen yang, linux-usb, linux-kernel, linux-arm-kernel
The call to of_find_node_by_name returns a node pointer with refcount
incremented thus it must be explicitly decremented here after the last
usage.
The of_find_device_by_node() takes a reference to the underlying device
structure, we also should release that reference.
This patch fixes those 2 issues.
Signed-off-by: Wen Yang <yellowriver2010@hotmail.com>
Cc: Patrice Chotard <patrice.chotard@st.com>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-usb@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
drivers/usb/dwc3/dwc3-st.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/dwc3/dwc3-st.c b/drivers/usb/dwc3/dwc3-st.c
index 1608138..fdd90d2 100644
--- a/drivers/usb/dwc3/dwc3-st.c
+++ b/drivers/usb/dwc3/dwc3-st.c
@@ -262,17 +262,18 @@ static int st_dwc3_probe(struct platform_device *pdev)
ret = of_platform_populate(node, NULL, NULL, dev);
if (ret) {
dev_err(dev, "failed to add dwc3 core\n");
- goto undo_softreset;
+ goto put_node;
}
child_pdev = of_find_device_by_node(child);
if (!child_pdev) {
dev_err(dev, "failed to find dwc3 core device\n");
ret = -ENODEV;
- goto undo_softreset;
+ goto put_node;
}
dwc3_data->dr_mode = usb_get_dr_mode(&child_pdev->dev);
+ put_device(&child_pdev->dev);
/*
* Configure the USB port as device or host according to the static
@@ -283,15 +284,18 @@ static int st_dwc3_probe(struct platform_device *pdev)
ret = st_dwc3_drd_init(dwc3_data);
if (ret) {
dev_err(dev, "drd initialisation failed\n");
- goto undo_softreset;
+ goto put_node;
}
/* ST glue logic init */
st_dwc3_init(dwc3_data);
platform_set_drvdata(pdev, dwc3_data);
+ of_node_put(child);
return 0;
+put_node:
+ of_node_put(child);
undo_softreset:
reset_control_assert(dwc3_data->rstc_rst);
undo_powerdown:
--
2.7.4
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] USB: dwc3: add missing of_node_put()
2019-02-03 3:52 [PATCH] USB: dwc3: add missing of_node_put() wen yang
@ 2019-02-06 8:46 ` Patrice CHOTARD
0 siblings, 0 replies; 3+ messages in thread
From: Patrice CHOTARD @ 2019-02-06 8:46 UTC (permalink / raw)
To: wen yang, balbi, gregkh; +Cc: linux-arm-kernel, linux-usb, linux-kernel
Hi Wen
On 2/3/19 4:52 AM, wen yang wrote:
> The call to of_find_node_by_name returns a node pointer with refcount
> incremented thus it must be explicitly decremented here after the last
> usage.
> The of_find_device_by_node() takes a reference to the underlying device
> structure, we also should release that reference.
> This patch fixes those 2 issues.
>
> Signed-off-by: Wen Yang <yellowriver2010@hotmail.com>
> Cc: Patrice Chotard <patrice.chotard@st.com>
> Cc: Felipe Balbi <balbi@kernel.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-usb@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> ---
> drivers/usb/dwc3/dwc3-st.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-st.c b/drivers/usb/dwc3/dwc3-st.c
> index 1608138..fdd90d2 100644
> --- a/drivers/usb/dwc3/dwc3-st.c
> +++ b/drivers/usb/dwc3/dwc3-st.c
> @@ -262,17 +262,18 @@ static int st_dwc3_probe(struct platform_device *pdev)
> ret = of_platform_populate(node, NULL, NULL, dev);
> if (ret) {
> dev_err(dev, "failed to add dwc3 core\n");
> - goto undo_softreset;
> + goto put_node;
> }
>
> child_pdev = of_find_device_by_node(child);
> if (!child_pdev) {
> dev_err(dev, "failed to find dwc3 core device\n");
> ret = -ENODEV;
> - goto undo_softreset;
> + goto put_node;
> }
>
> dwc3_data->dr_mode = usb_get_dr_mode(&child_pdev->dev);
> + put_device(&child_pdev->dev);
>
> /*
> * Configure the USB port as device or host according to the static
> @@ -283,15 +284,18 @@ static int st_dwc3_probe(struct platform_device *pdev)
> ret = st_dwc3_drd_init(dwc3_data);
> if (ret) {
> dev_err(dev, "drd initialisation failed\n");
> - goto undo_softreset;
> + goto put_node;
> }
>
> /* ST glue logic init */
> st_dwc3_init(dwc3_data);
>
> platform_set_drvdata(pdev, dwc3_data);
> + of_node_put(child);
> return 0;
>
> +put_node:
> + of_node_put(child);
> undo_softreset:
> reset_control_assert(dwc3_data->rstc_rst);
> undo_powerdown:
>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] USB: dwc3: add missing of_node_put()
@ 2019-02-06 8:46 ` Patrice CHOTARD
0 siblings, 0 replies; 3+ messages in thread
From: Patrice CHOTARD @ 2019-02-06 8:46 UTC (permalink / raw)
To: wen yang, balbi, gregkh; +Cc: linux-usb, linux-kernel, linux-arm-kernel
Hi Wen
On 2/3/19 4:52 AM, wen yang wrote:
> The call to of_find_node_by_name returns a node pointer with refcount
> incremented thus it must be explicitly decremented here after the last
> usage.
> The of_find_device_by_node() takes a reference to the underlying device
> structure, we also should release that reference.
> This patch fixes those 2 issues.
>
> Signed-off-by: Wen Yang <yellowriver2010@hotmail.com>
> Cc: Patrice Chotard <patrice.chotard@st.com>
> Cc: Felipe Balbi <balbi@kernel.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-usb@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> ---
> drivers/usb/dwc3/dwc3-st.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-st.c b/drivers/usb/dwc3/dwc3-st.c
> index 1608138..fdd90d2 100644
> --- a/drivers/usb/dwc3/dwc3-st.c
> +++ b/drivers/usb/dwc3/dwc3-st.c
> @@ -262,17 +262,18 @@ static int st_dwc3_probe(struct platform_device *pdev)
> ret = of_platform_populate(node, NULL, NULL, dev);
> if (ret) {
> dev_err(dev, "failed to add dwc3 core\n");
> - goto undo_softreset;
> + goto put_node;
> }
>
> child_pdev = of_find_device_by_node(child);
> if (!child_pdev) {
> dev_err(dev, "failed to find dwc3 core device\n");
> ret = -ENODEV;
> - goto undo_softreset;
> + goto put_node;
> }
>
> dwc3_data->dr_mode = usb_get_dr_mode(&child_pdev->dev);
> + put_device(&child_pdev->dev);
>
> /*
> * Configure the USB port as device or host according to the static
> @@ -283,15 +284,18 @@ static int st_dwc3_probe(struct platform_device *pdev)
> ret = st_dwc3_drd_init(dwc3_data);
> if (ret) {
> dev_err(dev, "drd initialisation failed\n");
> - goto undo_softreset;
> + goto put_node;
> }
>
> /* ST glue logic init */
> st_dwc3_init(dwc3_data);
>
> platform_set_drvdata(pdev, dwc3_data);
> + of_node_put(child);
> return 0;
>
> +put_node:
> + of_node_put(child);
> undo_softreset:
> reset_control_assert(dwc3_data->rstc_rst);
> undo_powerdown:
>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Thanks
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-02-06 8:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-03 3:52 [PATCH] USB: dwc3: add missing of_node_put() wen yang
2019-02-06 8:46 ` Patrice CHOTARD
2019-02-06 8:46 ` Patrice CHOTARD
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.