Skip to content

Commit

Permalink
usb: dwc3: xilinx: Handle dr_mode setting from DT properly
Browse files Browse the repository at this point in the history
In the current code, the dr_mode is being read from device-tree and is
compared against the available dr_modes to determine the controller
mode. However if the dr_mode property is not available in the DT then
this will result in crash due to improper handling.

Signed-off-by: Manish Narani <manish.narani@xilinx.com>
State: pending
  • Loading branch information
mnarani authored and Michal Simek committed May 27, 2021
1 parent d061717 commit 1a5c6a6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/usb/dwc3/dwc3-xilinx.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,10 @@ static int dwc3_xlnx_probe(struct platform_device *pdev)

/* get the dr_mode from child node */
ret = of_property_read_string(dwc3_child_node, "dr_mode", &dr_modes);
priv_data->dr_mode = usb_get_dr_mode_from_string(dr_modes);
if (ret < 0)
priv_data->dr_mode = USB_DR_MODE_UNKNOWN;
else
priv_data->dr_mode = usb_get_dr_mode_from_string(dr_modes);

of_node_put(dwc3_child_node);

Expand Down

0 comments on commit 1a5c6a6

Please sign in to comment.