Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4576093imu; Sat, 19 Jan 2019 12:47:42 -0800 (PST) X-Google-Smtp-Source: ALg8bN7a1UaLevDoZrHex3QS4ORMmC1NqICFv+mtVSndodBx+mqNb8B9Rh07DWrZmYYJD+1cx64Y X-Received: by 2002:a63:2e88:: with SMTP id u130mr23022718pgu.9.1547930862858; Sat, 19 Jan 2019 12:47:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547930862; cv=none; d=google.com; s=arc-20160816; b=C8rIr/TwwxFttj1N7O6uQCD+XpcQjMcXs04KlegVQDcuh/WrqvwIU9iPmcpzf5TvOJ 72joiOyjwhUtXgyz8hkDeSu5FdjDkOIvX75DPhc1l8/ADWUl+W3SwUMuwMxPhwd4JOAe rHqPS1EV0oq21K4R/6ELdMmijwrYQ9qcaTNlmY0igBo6JdpJoCLBat20S4g/IVrRrmr3 gRziTVfuuxy0OXKiEVALQ+TxzMUQCGS4YE/Aw33/4H+xXcGBq65gtxxdESXMCkFCiK7y NLRT5MF/hLrf+dcpjlOCKefS7ncIraDlNwfFeQeljrNmA9XDJLWvmw9u5qaxLNSpi6vP RlDA== 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=wdQ2qW0vuZRn0gFvpqdRFtFgKEXAeJTnEJfZxkPbk/8=; b=BD8DB0QfcraGZFxhpy5cTWB7mW04pv/iDMQC0m3/ap0BWlyokPZK2NQd5K6oCTipnK 2h1zRjCtQM0qAS5apqn9NoSvNvnRRByUYv//mBAh40TseAhxyqEn551i+pefXhHuQpYT cZmsLns9X4gMwRZiaFXt8mLamLxC3WWgu8UEY1TAjbMWZgmZRty/ne4nWr3Ov9Lkt3bg +Oa5qyGqGmTI4HKUsKQQTAhj49YxbLH4kPaBqX5Pg0FiFTNDfpPUbcDcDxvt5dDXoY3u Oi4R5BIMNl9HWc3hDLa7i3NGoT3H1919UkHm6wIAdyE1RYcozsoANyr9jS/JUo9NL6Bf lATw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@onstation.org header.s=default header.b=HrkWhBYR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b128si8863818pfa.283.2019.01.19.12.47.00; Sat, 19 Jan 2019 12:47:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@onstation.org header.s=default header.b=HrkWhBYR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729832AbfASUoE (ORCPT + 99 others); Sat, 19 Jan 2019 15:44:04 -0500 Received: from onstation.org ([52.200.56.107]:35202 "EHLO onstation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729643AbfASUnj (ORCPT ); Sat, 19 Jan 2019 15:43:39 -0500 Received: from localhost.localdomain (c-98-239-145-235.hsd1.wv.comcast.net [98.239.145.235]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: masneyb) by onstation.org (Postfix) with ESMTPSA id 83021503; Sat, 19 Jan 2019 20:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=onstation.org; s=default; t=1547930619; bh=9/ZgB2rAElIHFwQnk7Noa7Re6R+SEpAAMBAzdo67szY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HrkWhBYRQIyglQe2Y+oPD5eG2B+sAt9epJw+8S+zZFzAkyP2iUSRWYKCmNqbDqTCf XMyf1Aap5Jpo+LgHQ83JRhzmY1TymJQwNCU1kFMSEuO4XJF2Ja48qI+hy5NqzahEse Vs9sNHoev04eGt4BXirNfoA6SNc+qf1sU3W8zdsM= From: Brian Masney To: linus.walleij@linaro.org, sboyd@kernel.org, bjorn.andersson@linaro.org, andy.gross@linaro.org, marc.zyngier@arm.com Cc: shawnguo@kernel.org, dianders@chromium.org, linux-gpio@vger.kernel.org, nicolas.dechesne@linaro.org, niklas.cassel@linaro.org, david.brown@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, thierry.reding@gmail.com, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v6 14/15] spmi: pmic-arb: validate type when mapping IRQ Date: Sat, 19 Jan 2019 15:42:51 -0500 Message-Id: <20190119204252.18370-15-masneyb@onstation.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190119204252.18370-1-masneyb@onstation.org> References: <20190119204252.18370-1-masneyb@onstation.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org qpnpint_irq_domain_map did not validate the IRQ type and this can cause IRQs to not work as expected if an unsupported type (such as IRQ_TYPE_NONE) is passed in. Now that spmi-gpio is a hierarchical IRQ controller, and all device tree bindings have been updated, add additional validation to the type field. Signed-off-by: Brian Masney --- Patch introduced in v6 drivers/spmi/spmi-pmic-arb.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c index bc7dc1d6e4b2..5666b99c9a92 100644 --- a/drivers/spmi/spmi-pmic-arb.c +++ b/drivers/spmi/spmi-pmic-arb.c @@ -740,9 +740,9 @@ static int qpnpint_irq_domain_translate(struct irq_domain *d, } -static void qpnpint_irq_domain_map(struct spmi_pmic_arb *pmic_arb, - struct irq_domain *domain, unsigned int virq, - irq_hw_number_t hwirq, unsigned int type) +static int qpnpint_irq_domain_map(struct spmi_pmic_arb *pmic_arb, + struct irq_domain *domain, unsigned int virq, + irq_hw_number_t hwirq, unsigned int type) { irq_flow_handler_t handler; unsigned int old_virq; @@ -756,11 +756,15 @@ static void qpnpint_irq_domain_map(struct spmi_pmic_arb *pmic_arb, if (type & IRQ_TYPE_EDGE_BOTH) handler = handle_edge_irq; - else + else if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH)) handler = handle_level_irq; + else + return -EINVAL; irq_domain_set_info(domain, virq, hwirq, &pmic_arb_irqchip, pmic_arb, handler, NULL, NULL); + + return 0; } static int qpnpint_irq_domain_alloc(struct irq_domain *domain, @@ -777,9 +781,12 @@ static int qpnpint_irq_domain_alloc(struct irq_domain *domain, if (ret) return ret; - for (i = 0; i < nr_irqs; i++) - qpnpint_irq_domain_map(pmic_arb, domain, virq + i, hwirq + i, - type); + for (i = 0; i < nr_irqs; i++) { + ret = qpnpint_irq_domain_map(pmic_arb, domain, virq + i, + hwirq + i, type); + if (ret) + return ret; + } return 0; } -- 2.17.2