Skip to content

Commit

Permalink
usb: dwc3: st: Add of_dev_put() in probe function
Browse files Browse the repository at this point in the history
In function st_dwc3_probe, variable child_pdev takes the value returned
by of_find_device_by_node, which gets a device pointer but does not put
it. If child_pdev is not put before the probe function returns, it may
cause a reference leak. Hence put child_pdev after its last usage.
Issue found with Coccinelle.

Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
  • Loading branch information
gaurijhangiani authored and Felipe Balbi committed Aug 28, 2019
1 parent e36721b commit bceb418
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/usb/dwc3/dwc3-st.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ static int st_dwc3_probe(struct platform_device *pdev)

dwc3_data->dr_mode = usb_get_dr_mode(&child_pdev->dev);
of_node_put(child);
of_dev_put(child_pdev);

/*
* Configure the USB port as device or host according to the static
Expand Down

0 comments on commit bceb418

Please sign in to comment.