From patchwork Wed Jun 12 14:26:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 166573 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3752135ilk; Wed, 12 Jun 2019 07:27:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqw0OynFvyq0nN2sNFeuivqxKpVT4fzqGUCCuOpiN/n8tZiasM14a0u5QEgdf1sWF9Bno/dZ X-Received: by 2002:a63:5f0d:: with SMTP id t13mr19079168pgb.358.1560349631297; Wed, 12 Jun 2019 07:27:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560349631; cv=none; d=google.com; s=arc-20160816; b=lBsqXrLDy5FH9vIQD0JK2cMVkq50VyeumcD5WqanaxkF4wmkTRLJKiAFWXqcMEdgQb RZTjpENyi5nYm0+sdRoPSRXZ8Q0o12sTcVM+3qC/EH0oP2bAIPlCbpZfXbL01mkR8RdH 0qNKQETEUuQVdUFqCjpvwZ5IMnm+F0rf1IWjjdD+IfWgMB2+DW8MZGlHA7PT0/9xwG3u nRCOBAkgOHbpADxQyNILOE1iVGCU9Hl62ZxmIhGzghb9QKz7dvtklxZ2KfCZ0/rPK71C 8CZkuHqt35P3oqs4i54BOKnuPDipGtL+R9FwxzAAQOOyeni+Bo0eTw2TxR6inZj+prpG 7oWg== 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=SNz1EKDW514e8vAMK7oEUw0xGjovBkRHbCrNnu+mAspt6j9L1TvnsxmHfKLl5zYLou yFdN5gSx1LOcu8jB0kuwTel4A/O6080TdFQeys7i1J9dKdDk3LuOvxxfoTX9Z8DX8rF/ G9DRie1XDsPL+N0Ig2CuaFWZnnoJd49AB5uERR1ZqcCbcOJ1skqtb5AO1Sx2uT3D5FHZ dqv38wBb1p7BNBQDeHIUruAOIc8onAugzWc4Ev00bWkvA0q6kIYx6T3r9IhNHCx+mBYo yfb9T13lw+Up1fu+V9HbYmptqdf4YfkaPv4DyWoPB1GCWQC15Tblp1taKyjb42JxXGNC ffqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K+P6qWGc; 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 v10si16576992plg.320.2019.06.12.07.27.11; Wed, 12 Jun 2019 07:27:11 -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=K+P6qWGc; 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 S2439657AbfFLO1K (ORCPT + 5 others); Wed, 12 Jun 2019 10:27:10 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:33343 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439656AbfFLO1H (ORCPT ); Wed, 12 Jun 2019 10:27:07 -0400 Received: by mail-wm1-f65.google.com with SMTP id h19so4418119wme.0 for ; Wed, 12 Jun 2019 07:27:05 -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=K+P6qWGcKWtU/iGNHzOV9jjR+RXyRp8egtBtmeeUZNHtvIIVBJLVzsH3Vy3gAMuwgR Ao6Mudj+9wGNnHwdrOfxdgHdBdIcy5MyVOGRSFy+u/wbSjuIQHDF55F9J3zqhVi/3bzW 5HtveVGkaSLRv+2iEeE0w1LhFjT4UWtVB79zLW2+qAbLhdEdMRRAWva9Df2T5N4cUgds 7+g7+Wl3XKZO1rJ7uvAaX/LDxFQBwuJvjUCgufBdOzBsYf9UsfRDcBji+JpUDqmSS7Q4 /AWCGhD4M9fDnPW+0gkmxkwUaYgWL72BfJzZ7ePa8q3MSEccMjIXUPf0b5gg6hRk1f2l pkEA== 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=BmC15x3b1I078QvLUTzaygOrlLVPWlanK6w8i/Vu8ur/atNY+0mzq7O6aetOx17jxQ Cl3NiS3p5WcLJcYOjPyjoJ+29b1UwTUEz5mMeP10vWufqtC3kBon2s2n5KKLXinkI/yD iX5k47hnAjuyVimqx9ucUF/ur36swOGyo3CTjz2kbEiGVswroo5A2gCKlVUrgjpgKo9I /667oz830g3ioMcLUbFkyhqmHfn3cssfkA6moIhPSvEPAjlN9RzNMfJZP5uTO6QcEgNM BRzFfXtsvRE0bV69PUf3/lb8b13OsDjxzJpuNUDy34/QJA1NKGvYfhQ95ceqCkO8Pe7T R1Hg== X-Gm-Message-State: APjAAAWe3AUP6n+8euU+xTRTmu88ij9mVX9SQ/7mcbsjJfow29sdHI7T XUZKpxl05qV62HkTZvDZbOV4ag== X-Received: by 2002:a1c:1fc2:: with SMTP id f185mr23429895wmf.154.1560349625039; Wed, 12 Jun 2019 07:27:05 -0700 (PDT) Received: from dell.watershed.co.uk ([185.80.132.160]) by smtp.gmail.com with ESMTPSA id y18sm203959wmd.29.2019.06.12.07.27.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Jun 2019 07:27:04 -0700 (PDT) From: Lee Jones To: alokc@codeaurora.org, agross@kernel.org, david.brown@linaro.org, wsa+renesas@sang-engineering.com, bjorn.andersson@linaro.org, balbi@kernel.org, gregkh@linuxfoundation.org, ard.biesheuvel@linaro.org, jlhugo@gmail.com Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-gpio@vger.kernel.org, linux-usb@vger.kernel.or, Lee Jones Subject: [PATCH v4 6/6] usb: dwc3: qcom: Improve error handling Date: Wed, 12 Jun 2019 15:26:54 +0100 Message-Id: <20190612142654.9639-7-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190612142654.9639-1-lee.jones@linaro.org> References: <20190612142654.9639-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,