All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pinctrl: qcom: qdf2xxx: improve error checking and reporting
@ 2015-11-10 15:57 ` Timur Tabi
  0 siblings, 0 replies; 14+ messages in thread
From: Timur Tabi @ 2015-11-10 15:57 UTC (permalink / raw)
  To: Linus Walleij, linux-gpio, Bjorn Andersson, linux-arm-kernel

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.

Signed-off-by: Timur Tabi <timur@codeaurora.org>
---
 drivers/pinctrl/qcom/pinctrl-qdf2xxx.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/qcom/pinctrl-qdf2xxx.c b/drivers/pinctrl/qcom/pinctrl-qdf2xxx.c
index e9ff3bc..f448534 100644
--- a/drivers/pinctrl/qcom/pinctrl-qdf2xxx.c
+++ b/drivers/pinctrl/qcom/pinctrl-qdf2xxx.c
@@ -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;
 
-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH] pinctrl: qcom: qdf2xxx: improve error checking and reporting
@ 2015-11-10 15:57 ` Timur Tabi
  0 siblings, 0 replies; 14+ messages in thread
From: Timur Tabi @ 2015-11-10 15:57 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Timur Tabi <timur@codeaurora.org>
---
 drivers/pinctrl/qcom/pinctrl-qdf2xxx.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/qcom/pinctrl-qdf2xxx.c b/drivers/pinctrl/qcom/pinctrl-qdf2xxx.c
index e9ff3bc..f448534 100644
--- a/drivers/pinctrl/qcom/pinctrl-qdf2xxx.c
+++ b/drivers/pinctrl/qcom/pinctrl-qdf2xxx.c
@@ -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;
 
-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH] pinctrl: qcom: qdf2xxx: improve error checking and reporting
  2015-11-10 15:57 ` Timur Tabi
@ 2015-11-17 13:33   ` Linus Walleij
  -1 siblings, 0 replies; 14+ messages in thread
From: Linus Walleij @ 2015-11-17 13:33 UTC (permalink / raw)
  To: Timur Tabi, Arnd Bergmann; +Cc: linux-gpio, Bjorn Andersson, linux-arm-kernel

On Tue, Nov 10, 2015 at 4:57 PM, Timur Tabi <timur@codeaurora.org> wrote:

> 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.
>
> Signed-off-by: Timur Tabi <timur@codeaurora.org>

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
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH] pinctrl: qcom: qdf2xxx: improve error checking and reporting
@ 2015-11-17 13:33   ` Linus Walleij
  0 siblings, 0 replies; 14+ messages in thread
From: Linus Walleij @ 2015-11-17 13:33 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Nov 10, 2015 at 4:57 PM, Timur Tabi <timur@codeaurora.org> wrote:

> 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.
>
> Signed-off-by: Timur Tabi <timur@codeaurora.org>

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] pinctrl: qcom: qdf2xxx: improve error checking and reporting
  2015-11-17 13:33   ` Linus Walleij
@ 2015-11-17 13:36     ` Timur Tabi
  -1 siblings, 0 replies; 14+ messages in thread
From: Timur Tabi @ 2015-11-17 13:36 UTC (permalink / raw)
  To: Linus Walleij, Arnd Bergmann
  Cc: linux-gpio, Bjorn Andersson, linux-arm-kernel

Linus Walleij wrote:
> 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.

-- 
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.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH] pinctrl: qcom: qdf2xxx: improve error checking and reporting
@ 2015-11-17 13:36     ` Timur Tabi
  0 siblings, 0 replies; 14+ messages in thread
From: Timur Tabi @ 2015-11-17 13:36 UTC (permalink / raw)
  To: linux-arm-kernel

Linus Walleij wrote:
> 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.

-- 
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.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] pinctrl: qcom: qdf2xxx: improve error checking and reporting
  2015-11-17 13:33   ` Linus Walleij
@ 2015-11-17 14:15     ` Arnd Bergmann
  -1 siblings, 0 replies; 14+ messages in thread
From: Arnd Bergmann @ 2015-11-17 14:15 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Timur Tabi, linux-gpio, Bjorn Andersson, linux-arm-kernel

On Tuesday 17 November 2015 14:33:49 Linus Walleij wrote:
> On Tue, Nov 10, 2015 at 4:57 PM, Timur Tabi <timur@codeaurora.org> wrote:
> 
> > 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.
> >
> > Signed-off-by: Timur Tabi <timur@codeaurora.org>
> 
> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH] pinctrl: qcom: qdf2xxx: improve error checking and reporting
@ 2015-11-17 14:15     ` Arnd Bergmann
  0 siblings, 0 replies; 14+ messages in thread
From: Arnd Bergmann @ 2015-11-17 14:15 UTC (permalink / raw)
  To: linux-arm-kernel

On Tuesday 17 November 2015 14:33:49 Linus Walleij wrote:
> On Tue, Nov 10, 2015 at 4:57 PM, Timur Tabi <timur@codeaurora.org> wrote:
> 
> > 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.
> >
> > Signed-off-by: Timur Tabi <timur@codeaurora.org>
> 
> 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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] pinctrl: qcom: qdf2xxx: improve error checking and reporting
  2015-11-17 13:36     ` Timur Tabi
@ 2015-11-17 14:44       ` Linus Walleij
  -1 siblings, 0 replies; 14+ messages in thread
From: Linus Walleij @ 2015-11-17 14:44 UTC (permalink / raw)
  To: Timur Tabi; +Cc: Arnd Bergmann, linux-gpio, Bjorn Andersson, linux-arm-kernel

On Tue, Nov 17, 2015 at 2:36 PM, Timur Tabi <timur@codeaurora.org> wrote:
> Linus Walleij wrote:
>>
>> 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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH] pinctrl: qcom: qdf2xxx: improve error checking and reporting
@ 2015-11-17 14:44       ` Linus Walleij
  0 siblings, 0 replies; 14+ messages in thread
From: Linus Walleij @ 2015-11-17 14:44 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Nov 17, 2015 at 2:36 PM, Timur Tabi <timur@codeaurora.org> wrote:
> Linus Walleij wrote:
>>
>> 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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] pinctrl: qcom: qdf2xxx: improve error checking and reporting
  2015-11-10 15:57 ` Timur Tabi
@ 2015-11-23 18:02   ` Bjorn Andersson
  -1 siblings, 0 replies; 14+ messages in thread
From: Bjorn Andersson @ 2015-11-23 18:02 UTC (permalink / raw)
  To: Timur Tabi; +Cc: Linus Walleij, linux-gpio, linux-arm-kernel

On Tue 10 Nov 07:57 PST 2015, Timur Tabi wrote:

> 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.
> 
> Signed-off-by: Timur Tabi <timur@codeaurora.org>

Reviewed-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>

Regards,
Bjorn

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH] pinctrl: qcom: qdf2xxx: improve error checking and reporting
@ 2015-11-23 18:02   ` Bjorn Andersson
  0 siblings, 0 replies; 14+ messages in thread
From: Bjorn Andersson @ 2015-11-23 18:02 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue 10 Nov 07:57 PST 2015, Timur Tabi wrote:

> 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.
> 
> Signed-off-by: Timur Tabi <timur@codeaurora.org>

Reviewed-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>

Regards,
Bjorn

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] pinctrl: qcom: qdf2xxx: improve error checking and reporting
  2015-11-10 15:57 ` Timur Tabi
@ 2015-12-01  8:59   ` Linus Walleij
  -1 siblings, 0 replies; 14+ messages in thread
From: Linus Walleij @ 2015-12-01  8:59 UTC (permalink / raw)
  To: Timur Tabi; +Cc: linux-gpio, Bjorn Andersson, linux-arm-kernel

On Tue, Nov 10, 2015 at 4:57 PM, Timur Tabi <timur@codeaurora.org> wrote:

> 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.
>
> Signed-off-by: Timur Tabi <timur@codeaurora.org>

Patch applied with Björn's review tag.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH] pinctrl: qcom: qdf2xxx: improve error checking and reporting
@ 2015-12-01  8:59   ` Linus Walleij
  0 siblings, 0 replies; 14+ messages in thread
From: Linus Walleij @ 2015-12-01  8:59 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Nov 10, 2015 at 4:57 PM, Timur Tabi <timur@codeaurora.org> wrote:

> 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.
>
> Signed-off-by: Timur Tabi <timur@codeaurora.org>

Patch applied with Bj?rn's review tag.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2015-12-01  8:59 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-10 15:57 [PATCH] pinctrl: qcom: qdf2xxx: improve error checking and reporting Timur Tabi
2015-11-10 15:57 ` Timur Tabi
2015-11-17 13:33 ` Linus Walleij
2015-11-17 13:33   ` Linus Walleij
2015-11-17 13:36   ` Timur Tabi
2015-11-17 13:36     ` Timur Tabi
2015-11-17 14:44     ` Linus Walleij
2015-11-17 14:44       ` Linus Walleij
2015-11-17 14:15   ` Arnd Bergmann
2015-11-17 14:15     ` Arnd Bergmann
2015-11-23 18:02 ` Bjorn Andersson
2015-11-23 18:02   ` Bjorn Andersson
2015-12-01  8:59 ` Linus Walleij
2015-12-01  8:59   ` Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.