From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADD0DC28CC5 for ; Wed, 5 Jun 2019 07:02:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 888C920870 for ; Wed, 5 Jun 2019 07:02:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="k2mgUNFS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726510AbfFEHCq (ORCPT ); Wed, 5 Jun 2019 03:02:46 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:40862 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726407AbfFEHCq (ORCPT ); Wed, 5 Jun 2019 03:02:46 -0400 Received: by mail-pf1-f195.google.com with SMTP id u17so14290204pfn.7 for ; Wed, 05 Jun 2019 00:02:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=uz4rW4hom4PNyImhqoO7mrnt+7yVJFQ+a19gRd/J1UQ=; b=k2mgUNFS8mlgZJLWSI2R4t0x6v3cRS5Cibzq9KsQeI9KAoK6H7pBodfPO0qs0J/hBF UnokjKUh6mu48Jv152LXpaxAIemY3F4zfzFSo9NysiwGnJDt8ax3RxYRET3ra0TkQP/i GPnwx+W3Hhu5yRpNgUdOJGq+0KClDNJKtGTSYKeDaXwRrQBMN/34vs9cIw762gGL2S2X aCq0lADu9jfpEF0rmoDeGo70ZA4BURwaE5YhZ1GEYO/HYwHMaLZ9hL3hbjNuPqnF1VEN qBKuQPkKiY/bWef19eOPrZkK5kuzU+JYYp1dQcFzU8F63bw09h+yuZibsYe9AOcoI0tB VAcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=uz4rW4hom4PNyImhqoO7mrnt+7yVJFQ+a19gRd/J1UQ=; b=JRMqayUhi/LC19RjERVRNnIKVkE7XR9gkXnKDy0TQuggGankEh5bDdDEWgHS1+8YO8 /02vdfIAJfhPYauPBZdbibdNnsdtxr5WfMhiPp5KeunRPIyAQWyTWMUQ0GxI2HvNGQbo wpL3r6Rtru51n7LjR8daeL9skXYERL4gMyffbAl/058qmjlWfPRRQ6Fto2Iws1wL3E1P AGpmaAcYuI8ob4476NI6yAMLB6+nC6aYFGuPrugd/5QNaI6zQeqhpN4kWDy0eet9kM9H +dK9c0P+s17GmSGCq+tV9Tx8mR0LbOjq5wvPCIq3Y6VHtxFfTCi7a/aUeNIK6re6TwKr 6vsw== X-Gm-Message-State: APjAAAUE9YDahPos/SRAWRkCHBMgT6pA+dGdoPVNf6SAYM+QbKKLuiQ5 qfJMpfd2VsYekfxL6A49STZhnRtjW6o= X-Google-Smtp-Source: APXvYqxbp1TM7o6DxILTBx5tTuqENvUDU+OcxxTSnQwTp/YO/ccBSoR/xNWDWoB8WKd14PCiX3fHZQ== X-Received: by 2002:a63:fa16:: with SMTP id y22mr2444462pgh.15.1559718165590; Wed, 05 Jun 2019 00:02:45 -0700 (PDT) Received: from tuxbook-pro (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id w62sm7765452pfw.132.2019.06.05.00.02.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Jun 2019 00:02:45 -0700 (PDT) Date: Wed, 5 Jun 2019 00:03:30 -0700 From: Bjorn Andersson 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 Subject: Re: [PATCH 8/8] usb: dwc3: qcom: Improve error handling 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 Content-Disposition: inline In-Reply-To: <20190604104455.8877-8-lee.jones@linaro.org> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 >