lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1589817025-21886-1-git-send-email-groverm@codeaurora.org>
Date:   Mon, 18 May 2020 21:20:25 +0530
From:   Mayank Grover <groverm@...eaurora.org>
To:     linus.walleij@...aro.org, agross@...nel.org,
        bjorn.andersson@...aro.org
Cc:     linux-gpio@...r.kernel.org, linux-arm-msm@...r.kernel.org,
        linux-kernel@...r.kernel.org, neeraju@...eaurora.org,
        Mayank Grover <groverm@...eaurora.org>
Subject: [PATCH] pinctrl: msm: Add check for pinctrl group is valid

The list of reserved gpio pins for platform are populated
in gpiochip valid_mask.

Here on MSM common driver introduce ability to check if
pingroup is valid, by parsing pins in pingroup against
reserved pins for gpios. This does not handle non-gpio
pingroups.

Signed-off-by: Mayank Grover <groverm@...eaurora.org>
---
 drivers/pinctrl/qcom/pinctrl-msm.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c
index 85858c1..b6ebe26 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm.c
@@ -261,6 +261,24 @@ static unsigned msm_regval_to_drive(u32 val)
 	return (val + 1) * 2;
 }
 
+static bool msm_pingroup_is_valid(struct msm_pinctrl *pctrl,
+				  const struct msm_pingroup *g)
+{
+	const unsigned int *pins = g->pins;
+	unsigned int num_pins = g->npins;
+	struct gpio_chip *chip = &pctrl->chip;
+	unsigned int max_gpios = chip->ngpio;
+	unsigned int i;
+
+	for (i = 0; i < num_pins; i++) {
+		/* Doesn't handle non-gpio pingroups */
+		if (pins[i] < max_gpios &&
+		    !gpiochip_line_is_valid(chip, pins[i]))
+			return false;
+	}
+	return true;
+}
+
 static int msm_config_group_get(struct pinctrl_dev *pctldev,
 				unsigned int group,
 				unsigned long *config)
@@ -276,6 +294,10 @@ static int msm_config_group_get(struct pinctrl_dev *pctldev,
 
 	g = &pctrl->soc->groups[group];
 
+	/* Check if group has all valid pins */
+	if (!msm_pingroup_is_valid(pctrl, g))
+		return -EINVAL;
+
 	ret = msm_config_reg(pctrl, g, param, &mask, &bit);
 	if (ret < 0)
 		return ret;
@@ -355,6 +377,10 @@ static int msm_config_group_set(struct pinctrl_dev *pctldev,
 
 	g = &pctrl->soc->groups[group];
 
+	/* Check if group has all valid pins */
+	if (!msm_pingroup_is_valid(pctrl, g))
+		return -EINVAL;
+
 	for (i = 0; i < num_configs; i++) {
 		param = pinconf_to_config_param(configs[i]);
 		arg = pinconf_to_config_argument(configs[i]);
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
member of the Code Aurora Forum, hosted by The Linux Foundation

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ