[PATCH] soc: fsl: qe: gpio: Fix an error code in qe_pin_request()

Subsystems: freescale quicc engine library, freescale soc drivers, the rest

STALE2652d

3 messages, 2 authors, 2019-05-03 · open the first message on its own page

[PATCH] soc: fsl: qe: gpio: Fix an error code in qe_pin_request()

From: Dan Carpenter <hidden>
Date: 2019-05-03 13:19:14

There was a missing error code in this path.  It meant that we returned
ERR_PTR(0) which is NULL and would result in a NULL dereference in the
caller.

Fixes: 1a2d397a6eb5 ("gpio/powerpc: Eliminate duplication of of_get_named_gpio_flags()")
Signed-off-by: Dan Carpenter <redacted>
---
 drivers/soc/fsl/qe/gpio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/soc/fsl/qe/gpio.c b/drivers/soc/fsl/qe/gpio.c
index 819bed0f5667..51b3a47b5a55 100644
--- a/drivers/soc/fsl/qe/gpio.c
+++ b/drivers/soc/fsl/qe/gpio.c
@@ -179,8 +179,10 @@ struct qe_pin *qe_pin_request(struct device_node *np, int index)
 	if (err < 0)
 		goto err0;
 	gc = gpio_to_chip(err);
-	if (WARN_ON(!gc))
+	if (WARN_ON(!gc)) {
+		err = -ENODEV;
 		goto err0;
+	}
 
 	if (!of_device_is_compatible(gc->of_node, "fsl,mpc8323-qe-pario-bank")) {
 		pr_debug("%s: tried to get a non-qe pin\n", __func__);
-- 
2.18.0

Re: [PATCH] soc: fsl: qe: gpio: Fix an error code in qe_pin_request()

From: Li Yang <hidden>
Date: 2019-05-03 18:46:58

On Fri, May 3, 2019 at 8:19 AM Dan Carpenter [off-list ref] wrote:
There was a missing error code in this path.  It meant that we returned
ERR_PTR(0) which is NULL and would result in a NULL dereference in the
caller.
Thanks Dan.  An early version of this patch has been included in a
pending pull request to arm-soc.
https://lkml.org/lkml/2019/5/1/506

quoted hunk
Fixes: 1a2d397a6eb5 ("gpio/powerpc: Eliminate duplication of of_get_named_gpio_flags()")
Signed-off-by: Dan Carpenter <redacted>
---
 drivers/soc/fsl/qe/gpio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/soc/fsl/qe/gpio.c b/drivers/soc/fsl/qe/gpio.c
index 819bed0f5667..51b3a47b5a55 100644
--- a/drivers/soc/fsl/qe/gpio.c
+++ b/drivers/soc/fsl/qe/gpio.c
@@ -179,8 +179,10 @@ struct qe_pin *qe_pin_request(struct device_node *np, int index)
        if (err < 0)
                goto err0;
        gc = gpio_to_chip(err);
-       if (WARN_ON(!gc))
+       if (WARN_ON(!gc)) {
+               err = -ENODEV;
                goto err0;
+       }

        if (!of_device_is_compatible(gc->of_node, "fsl,mpc8323-qe-pario-bank")) {
                pr_debug("%s: tried to get a non-qe pin\n", __func__);
--
2.18.0

Re: [PATCH] soc: fsl: qe: gpio: Fix an error code in qe_pin_request()

From: Dan Carpenter <hidden>
Date: 2019-05-03 19:44:50

On Fri, May 03, 2019 at 01:45:07PM -0500, Li Yang wrote:
On Fri, May 3, 2019 at 8:19 AM Dan Carpenter [off-list ref] wrote:
quoted
There was a missing error code in this path.  It meant that we returned
ERR_PTR(0) which is NULL and would result in a NULL dereference in the
caller.
Thanks Dan.  An early version of this patch has been included in a
pending pull request to arm-soc.
https://lkml.org/lkml/2019/5/1/506
Oops.  Sorry, I switched computers and forgot to copy my old outbox
over.  :(

regards,
dan carpenter
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help