diff mbox series

usb: aspeed-vhub: Fix refcount leak bug in ast_vhub_init_desc()

Message ID 20220713120528.368168-1-windhl@126.com (mailing list archive)
State Accepted
Commit 220fafb4ed04187e9c17be4152da5a7f2ffbdd8c
Headers show
Series usb: aspeed-vhub: Fix refcount leak bug in ast_vhub_init_desc() | expand

Commit Message

Liang He July 13, 2022, 12:05 p.m. UTC
We should call of_node_put() for the reference returned by
of_get_child_by_name() which has increased the refcount.

Fixes: 30d2617fd7ed ("usb: gadget: aspeed: allow to set usb strings in device tree")
Signed-off-by: Liang He <windhl@126.com>
---
 drivers/usb/gadget/udc/aspeed-vhub/hub.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Andrew Jeffery July 18, 2022, 1 a.m. UTC | #1
On Wed, 13 Jul 2022, at 21:35, Liang He wrote:
> We should call of_node_put() for the reference returned by
> of_get_child_by_name() which has increased the refcount.
>
> Fixes: 30d2617fd7ed ("usb: gadget: aspeed: allow to set usb strings in 
> device tree")
> Signed-off-by: Liang He <windhl@126.com>

Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
diff mbox series

Patch

diff --git a/drivers/usb/gadget/udc/aspeed-vhub/hub.c b/drivers/usb/gadget/udc/aspeed-vhub/hub.c
index 65cd4e46f031..e2207d014620 100644
--- a/drivers/usb/gadget/udc/aspeed-vhub/hub.c
+++ b/drivers/usb/gadget/udc/aspeed-vhub/hub.c
@@ -1059,8 +1059,10 @@  static int ast_vhub_init_desc(struct ast_vhub *vhub)
 	/* Initialize vhub String Descriptors. */
 	INIT_LIST_HEAD(&vhub->vhub_str_desc);
 	desc_np = of_get_child_by_name(vhub_np, "vhub-strings");
-	if (desc_np)
+	if (desc_np) {
 		ret = ast_vhub_of_parse_str_desc(vhub, desc_np);
+		of_node_put(desc_np);
+	}
 	else
 		ret = ast_vhub_str_alloc_add(vhub, &ast_vhub_strings);