From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bjorn Andersson Subject: Re: [PATCH 8/8] usb: dwc3: qcom: Improve error handling Date: Wed, 5 Jun 2019 00:03:30 -0700 Message-ID: <20190605070330.GO22737@tuxbook-pro> References: <20190604104455.8877-1-lee.jones@linaro.org> <20190604104455.8877-8-lee.jones@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20190604104455.8877-8-lee.jones@linaro.org> Sender: linux-kernel-owner@vger.kernel.org To: Lee Jones Cc: alokc@codeaurora.org, kramasub@codeaurora.org, andy.gross@linaro.org, david.brown@linaro.org, wsa+renesas@sang-engineering.com, linus.walleij@linaro.org, balbi@kernel.org, gregkh@linuxfoundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, jlhugo@gmail.com, linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-gpio@vger.kernel.org, linux-usb@vger.kernel.org List-Id: linux-i2c@vger.kernel.org On Tue 04 Jun 03:44 PDT 2019, Lee Jones wrote: > 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 Reviewed-by: Bjorn Andersson > --- > drivers/usb/dwc3/dwc3-qcom.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c > index f21fdd6cdd1a..633482926497 100644 > --- a/drivers/usb/dwc3/dwc3-qcom.c > +++ b/drivers/usb/dwc3/dwc3-qcom.c > @@ -419,6 +419,9 @@ static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count) > if (!count || ACPI_HANDLE(dev)) > return 0; > > + if (count < 0) > + return count; > + > qcom->clks = devm_kcalloc(dev, qcom->num_clocks, > sizeof(struct clk *), GFP_KERNEL); > if (!qcom->clks) > -- > 2.17.1 >