Skip to contentSkip to conversation

pinctrl: qcom: qdf2xxx: improve error checking and reporting

PATCH New Timur Tabi 4 participants 7 messages Nov 10, 2015 – Dec 1, 2015

Subsystems (5)
lore
Share & tools
lore

Timur Tabi

author
#0 lore raw

PATCH 1/1 pinctrl: qcom: qdf2xxx: improve error checking and reporting

The driver doesn't report an error message if the ACPI tables are missing the num-gpios property (which indicates how many GPIOs there are on this SOC), and it didn't check to ensure that the mallocs didn't fail.

---
 drivers/pinctrl/qcom/pinctrl-qdf2xxx.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/pinctrl/qcom/pinctrl-qdf2xxx.c +11 -3
index e9ff3bc..f448534 100644
@@ -32,6 +32,9 @@
 
 static struct msm_pinctrl_soc_data qdf2xxx_pinctrl;
 
+/* A reasonable limit to the number of GPIOS */
+#define MAX_GPIOS	256
+
 static int qdf2xxx_pinctrl_probe(struct platform_device *pdev)
 {
 	struct pinctrl_pin_desc *pins;
@@ -42,11 +45,13 @@ static int qdf2xxx_pinctrl_probe(struct platform_device *pdev)
 
 	/* Query the number of GPIOs from ACPI */
 	ret = device_property_read_u32(&pdev->dev, "num-gpios", &num_gpios);
-	if (ret < 0)
+	if (ret < 0) {
+		dev_warn(&pdev->dev, "missing num-gpios property\n");
 		return ret;
+	}
 
-	if (!num_gpios) {
-		dev_warn(&pdev->dev, "missing num-gpios property\n");
+	if (!num_gpios || num_gpios > MAX_GPIOS) {
+		dev_warn(&pdev->dev, "invalid num-gpios property\n");
 		return -ENODEV;
 	}
 
@@ -55,6 +60,9 @@ static int qdf2xxx_pinctrl_probe(struct platform_device *pdev)
 	groups = devm_kcalloc(&pdev->dev, num_gpios,
 		sizeof(struct msm_pingroup), GFP_KERNEL);
 
+	if (!pins || !groups)
+		return -ENOMEM;
+
 	for (i = 0; i < num_gpios; i++) {
 		pins[i].number = i;
 
Signature · 3 lines
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.
#1 lore raw

PATCH 1/1 pinctrl: qcom: qdf2xxx: improve error checking and reporting

Quoted 5 lines · Timur Tabi

The driver doesn't report an error message if the ACPI tables are missing the num-gpios property (which indicates how many GPIOs there are on this SOC), and it didn't check to ensure that the mallocs didn't fail.

Waiting for Bj?rn's ACK on this.

And I suspect Arnd would be interested to know if you are doing ACPI on something that is certainly not a server-class hardware. Because you shouldn't.

Yours,
Linus Walleij

author
#2 lore raw

PATCH 1/1 pinctrl: qcom: qdf2xxx: improve error checking and reporting

Quoted 3 lines · Linus Walleij

And I suspect Arnd would be interested to know if you are doing ACPI on something that is certainly not a server-class hardware. Because you shouldn't.

This driver is for the TLMM pin control device on Qualcomm's ARM64 Server chip.

Signature · 3 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the
Code Aurora Forum, hosted by The Linux Foundation.
#3 lore raw

PATCH 1/1 pinctrl: qcom: qdf2xxx: improve error checking and reporting

Quoted 8 lines · Timur Tabi
Quoted 4 lines · Linus Walleij

And I suspect Arnd would be interested to know if you are doing ACPI on something that is certainly not a server-class hardware. Because you shouldn't.

This driver is for the TLMM pin control device on Qualcomm's ARM64 Server chip.

Ohhh sweet. OK then.

Yours,
Linus Walleij

#4 lore raw

PATCH 1/1 pinctrl: qcom: qdf2xxx: improve error checking and reporting

In reply to Linus Walleij
Quoted 6 lines · On Tuesday 17 November 2015 14:33:49 Linus Walleij wrote:
Quoted 4 lines · Timur Tabi

The driver doesn't report an error message if the ACPI tables are missing the num-gpios property (which indicates how many GPIOs there are on this SOC), and it didn't check to ensure that the mallocs didn't fail.

Quoted 8 lines
Quoted 1 line

Waiting for Bj?rn's ACK on this.

And I suspect Arnd would be interested to know if you are doing ACPI on something that is certainly not a server-class hardware. Because you shouldn't.

It's more fun just watching this really. No comment.

Arnd

#6 lore raw

PATCH 1/1 pinctrl: qcom: qdf2xxx: improve error checking and reporting

In reply to Timur Tabi
Quoted 5 lines · Timur Tabi

The driver doesn't report an error message if the ACPI tables are missing the num-gpios property (which indicates how many GPIOs there are on this SOC), and it didn't check to ensure that the mallocs didn't fail.

Patch applied with Bj?rn's review tag.

Yours,
Linus Walleij