From patchwork Fri Jun 7 08:29:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 166066 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp346205ili; Fri, 7 Jun 2019 01:29:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqzzDeKlsn7YT7gL4zlIjo/QTblm92ABGcQZos+wzsSQUl/9ohEviNlK/P2cDCmCAaYDLeKE X-Received: by 2002:a17:902:24d:: with SMTP id 71mr55822687plc.166.1559896155054; Fri, 07 Jun 2019 01:29:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559896155; cv=none; d=google.com; s=arc-20160816; b=WKd56DJveCVcDwRhTxV9XeStkkcWfyyekYG+qzJluIA+znXlrgyAla27nUjzqAFt6g Zy5V/LaQJ7nOG/0tbIat2y+AMHczb9slpmcdvX68lh10xr5tTWVw0HvA34aXX8ijw3py eKaROVYZyKMWnj1lZprpdRspMWMoCktUECC2xGF0S2r+y9Gk/dwaVR4eKW6sNJwjzTBR vNA4NLSzHp6WBRNa0faBirh3SrYFBPyYqVY1uAGVCSh9C0Mxmh+Ao94Nje/1GY0x6Kr9 kqfhB6VrizIwQIY5r2rM+ofc/ICHTq+SvDDNB49MmxtRQKD2mh5HnD+YFBhzFEe+sXdg 4LBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=FalRLEADzMPtGyW8NIPAA0F5olxzxXGnPVoGFb+myak=; b=UezV+NHs2lEMvvXFMWRm8mc6vxFB3nNLxGXZYhbNrHIGoy5Q5K0MgtHXThROty+tg0 ldrEzXCqIV3T2/bgTmWSz+je8f9TMjFVSuMeboyXP/V7a6Q/hNoWX79O57yQipb8P7AG LpH2TY9/1yQjKiuCAjvbWtzpyoUraU2nkW5nbl2j630kJlWClp9DsOTI+pO8BdlG0Uhw yaQnI/eVcvr+N9ix4EUsVpRs0gqOHwUFed718jjS0COpLJZg7O8p/xxRjZpEWhxLHenG 7aIgV5vQWpPykQJlfAJ4J+gSfCKFe55lHXjiyDzFdka1Q4b028jub7sh293iv6UDUQ75 K/Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="qS6/gC3g"; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r18si1186838pgv.433.2019.06.07.01.29.14; Fri, 07 Jun 2019 01:29:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="qS6/gC3g"; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727941AbfFGI3N (ORCPT + 5 others); Fri, 7 Jun 2019 04:29:13 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:33503 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728042AbfFGI3N (ORCPT ); Fri, 7 Jun 2019 04:29:13 -0400 Received: by mail-wr1-f65.google.com with SMTP id n9so1261114wru.0 for ; Fri, 07 Jun 2019 01:29:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FalRLEADzMPtGyW8NIPAA0F5olxzxXGnPVoGFb+myak=; b=qS6/gC3g0ivDxQeYTAyAXWuKblhoYJyrn1fhCTmRyYAb/dWfOeXaEtzpJDpgr4/keC y9YxUUGJsjTMzcLV0Xk+Gm3yNRHp+YTAA8eMqqZOxwkj8MByuQQdEKhqYlEO3weOrF7m Jm8HKR9UNUcaw6GVDTJe18vTDeIrxL/txUdpmREfkl/zV1qCJggDJ0qvOs0oFjXzfDhX QYmnCarRktfnHTYRBX9mOzCN0H8TbcO+skVCCW4zXhp9qmRFsbGuiOiABEgUZFpnmzsi uv5c8stevPakNzYje7bhOZlX4YXx0QxavvOfiqJC9mF+9fxItWO/Uh3ILMCG9Vx4dVGM pHYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FalRLEADzMPtGyW8NIPAA0F5olxzxXGnPVoGFb+myak=; b=qZQW1pIq16Sauk1KQKF278BU3tMjSwPmw/Z9Tb755vYScV6NxFA/lG0+YlG+/fW0cK 63mYsGpqKgb0JASahyp9ex5WTxoC9D+zxNgJoliNK13p4F5R3ict7TDB24zoApY+utSs 9hlQAUnpPR1qMX3IWRV6wHG8T+SPhKALqu9pugQNrkBBlVx6R/OldfjHMFDGmFXKhVLq XjUt2+aSA3EsU4C58mDjRYjPAFzgxzaBnv6tLEzaw2BAukpsiMkFNzgnDbelViQgSkIH oTExRM2L9np+/We3TKGkpWSWvD+HHsWZY2GirFdWKhI+RScce51uRqWr/NEcK8UDIHQe JyNg== X-Gm-Message-State: APjAAAWGP6sESjpBilmKDvd0KBjx98zKNSgqDIcp5lxCyOBYgwmKoiZh tPITBrWIRqX8scVIevdAZuWzDA== X-Received: by 2002:adf:ce8f:: with SMTP id r15mr21014523wrn.122.1559896151288; Fri, 07 Jun 2019 01:29:11 -0700 (PDT) Received: from localhost.localdomain ([2.31.167.229]) by smtp.gmail.com with ESMTPSA id a3sm1092946wmb.35.2019.06.07.01.29.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Jun 2019 01:29:10 -0700 (PDT) From: Lee Jones To: alokc@codeaurora.org, andy.gross@linaro.org, david.brown@linaro.org, wsa+renesas@sang-engineering.com, bjorn.andersson@linaro.org, linus.walleij@linaro.org, balbi@kernel.org, gregkh@linuxfoundation.org Cc: 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, Lee Jones Subject: [PATCH v2 8/8] usb: dwc3: qcom: Improve error handling Date: Fri, 7 Jun 2019 09:29:01 +0100 Message-Id: <20190607082901.6491-8-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190607082901.6491-1-lee.jones@linaro.org> References: <20190607082901.6491-1-lee.jones@linaro.org> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org 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(+) -- 2.17.1 diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c index 55ba04254e38..e4dac82abd7d 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,