diff options
author | Lee Jones <lee.jones@linaro.org> | 2019-06-17 14:51:05 +0200 |
---|---|---|
committer | Felipe Balbi <felipe.balbi@linux.intel.com> | 2019-06-18 10:58:29 +0200 |
commit | 7f5d6a4696170ca7394d9dcecd5a54ebe2b9a067 (patch) | |
tree | d5cd69bfe3318a4d1de71ab7e26575acb1997716 /drivers/usb/dwc3/dwc3-qcom.c | |
parent | usb: dwc3: qcom: Start USB in 'host mode' on the SDM845 (diff) | |
download | linux-7f5d6a4696170ca7394d9dcecd5a54ebe2b9a067.tar.xz linux-7f5d6a4696170ca7394d9dcecd5a54ebe2b9a067.zip |
usb: dwc3: qcom: Improve error handling
dwc3_qcom_clk_init() is called with of_count_phandle_with_args() as an
argument. If of_count_phandle_with_args() returns an error, the number
of clocks will be a negative value and will lead to undefined behaviour.
Ensure we check for an error before attempting to blindly use the value.
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Diffstat (limited to 'drivers/usb/dwc3/dwc3-qcom.c')
-rw-r--r-- | drivers/usb/dwc3/dwc3-qcom.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c index 2d050303d564..c59e9d8e8609 100644 --- a/drivers/usb/dwc3/dwc3-qcom.c +++ b/drivers/usb/dwc3/dwc3-qcom.c @@ -409,6 +409,9 @@ static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count) if (!np || !count) return 0; + if (count < 0) + return count; + qcom->num_clocks = count; qcom->clks = devm_kcalloc(dev, qcom->num_clocks, |