From patchwork Mon Jun 17 12:51:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 167017 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2823625ilk; Mon, 17 Jun 2019 05:51:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqyky+MnURwP88dH/FNnj1COi3TX1ir81HJRBYydYbEuAkxHhVUb4t+NK01Ujq1zBjIIp0tl X-Received: by 2002:a65:534b:: with SMTP id w11mr606432pgr.210.1560775879826; Mon, 17 Jun 2019 05:51:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560775879; cv=none; d=google.com; s=arc-20160816; b=rKsTV6eN+Xc+156h2HP07e21Ze+ABErEEyePEwfbbrfU5VKnRAdSAOjPgGNycBxyFF +XZSM2clKPrzoouzJRq3+gkk9nJjLIvo+BR8KnWYX9J/QmncSqREDJZpWJoCFlRVNj8L A35gxp+Xc+2qSJTm5tmw8h/VhwinV2ytQ19TSy5DYbEadXiimw5hZ+EoxNKTI9Oxkfhv WTNz3vNiL/Nzom5JVbvMEZe41qPUDu7NSSohhQS4Lhhu9yDP7SS0eEZK4bmgAPFW2CcK em2FGkLIyJDU/Syb49qsZhPmOZHWNrZ+rS+aW7ebaL0q77pLz/t0VO+oSTIvR7whRoAN CUKA== 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=Yh8KWN22mWMhTl8rcvEzBYBWJNOHxR/ZVbPRRDE/D+g=; b=PQ3FMNLgRZ7DQTw0aQaZ9whAuH10jhbf9CN/hkMIqyPLH9VEJUmGQszBNuRYR/Pw8B 2sSz2hrpa3g8jL497oKGRuvuuLWQnNhCDE4HOsirlGLr8041jO5Y743dt0DfwFEPONlp 7rhVfXImEe90er5nGgq9A09+lpRcqe/fka194BsGFqz7n+RBbJhjsuThxSHk+LzTxxaD l/Xbx4t4pE8lD2tyTiv3wZbhsggRnsMssjSSKUiowCMNqU4E6VzaSS0G9yncZ7uJPbY6 NCbgH9v5FxxkXxwouBCB1b4CiNkQk2pA0+X423dMaDSFnH6H/kpSpTuZsb9np+M3T8dO s+ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="q/VQwMJ7"; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 z5si10295268pfa.74.2019.06.17.05.51.19; Mon, 17 Jun 2019 05:51:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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="q/VQwMJ7"; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1726834AbfFQMvP (ORCPT + 15 others); Mon, 17 Jun 2019 08:51:15 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:50278 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727916AbfFQMvO (ORCPT ); Mon, 17 Jun 2019 08:51:14 -0400 Received: by mail-wm1-f66.google.com with SMTP id c66so9150623wmf.0 for ; Mon, 17 Jun 2019 05:51:13 -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=Yh8KWN22mWMhTl8rcvEzBYBWJNOHxR/ZVbPRRDE/D+g=; b=q/VQwMJ7CaCCS2TpiY40tB9SR/0BGYUD9cg5QmvyZlgN0oSe9DGo/a+8W3tFnih/es f/TGbxw2+NhrkghexAa4OElVuqj6adr3zChACFmOr55PBTOD/M1NIEdtp5/IEy9qU/kC fX2Qrs7PhDGqUidNClIWZ04Lwg4RW4iXSfsUN/mQ3Fz6ReP9i0AdV914a9optyVwxJ9W Xy6Y1mSeoVn1NeqGDQGLUT+gzK0PwP6QYlI5aEiS1G795pxPRN55vGKPX1Kr7l+p8xwx 9xxVx3Oo0mrnM/HpISh/Sd3kMq4WHV1BoTnn1nr+LgaU5NktIDT5p1PPAhig5lYx1wqZ dRuw== 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=Yh8KWN22mWMhTl8rcvEzBYBWJNOHxR/ZVbPRRDE/D+g=; b=mqr/jhM9XGd+l6Cun+utMIe4yZuhUP7g8AcOezx80qOR8fqsJav8Bifbsk21upsPdn AxOC68n8v/iECoAK/dVJJutgl26MW1IWK7sBeQysT9LaOnlUtN0dMQ+jwYp6/Onxdw0b jTV0wJ0sq2Ajrx0kW597j8VO4vdbNF2hZtSJkNKnOGQ7gcsFtAH5gakUwSIwqKsELPvN Bb7hsoXDufZa08DcMiRNa2XAMdNVkBk7TKwHTJiqupgrvJASKk7hLNfyeeBFTP/oaEhl CPiu9MsozESfvulG7gVoajogRK603c46x0NvPVEn0tfzX0i3ReotzXnddF3B8dr96z9F 3AmA== X-Gm-Message-State: APjAAAUR4tRjRWY8E1BiD268gXAGp24syo79dvELFyAQ6/3bN7M+d48K +c/li0i9RDfb6Cg4zN1nSTiGUA== X-Received: by 2002:a1c:63c4:: with SMTP id x187mr17953607wmb.4.1560775872645; Mon, 17 Jun 2019 05:51:12 -0700 (PDT) Received: from dell.watershed.co.uk ([2.27.35.243]) by smtp.gmail.com with ESMTPSA id o11sm10477852wmh.37.2019.06.17.05.51.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jun 2019 05:51:12 -0700 (PDT) From: Lee Jones To: alokc@codeaurora.org, agross@kernel.org, david.brown@linaro.org, bjorn.andersson@linaro.org, balbi@kernel.org, gregkh@linuxfoundation.org, ard.biesheuvel@linaro.org, jlhugo@gmail.com, linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, felipe.balbi@linux.intel.com Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Lee Jones Subject: [RESEND v4 4/4] usb: dwc3: qcom: Improve error handling Date: Mon, 17 Jun 2019 13:51:05 +0100 Message-Id: <20190617125105.6186-5-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190617125105.6186-1-lee.jones@linaro.org> References: <20190617125105.6186-1-lee.jones@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 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,