diff mbox series

serial: 8250_of: fix return code when probe function fails to get reset

Message ID 1514352065-7777-1-git-send-email-yamada.masahiro@socionext.com
State Accepted
Commit b9820a31691b771db37afe2054dd3d3a680c1eed
Headers show
Series serial: 8250_of: fix return code when probe function fails to get reset | expand

Commit Message

Masahiro Yamada Dec. 27, 2017, 5:21 a.m. UTC
The error pointer from devm_reset_control_get_optional_shared() is
not propagated.

One of the most common problem scenarios is it returns -EPROBE_DEFER
when the reset controller has not probed yet.  In this case, the
probe of the reset consumer should be deferred.

Fixes: e2860e1f62f2 ("serial: 8250_of: Add reset support")
Cc: stable@vger.kernel.org # v4.13+
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

---

 drivers/tty/serial/8250/8250_of.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

-- 
2.7.4

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

Comments

Philipp Zabel Jan. 2, 2018, 11:45 a.m. UTC | #1
Hi Masahiro,

On Wed, 2017-12-27 at 14:21 +0900, Masahiro Yamada wrote:
> The error pointer from devm_reset_control_get_optional_shared() is

> not propagated.

>

> One of the most common problem scenarios is it returns -EPROBE_DEFER

> when the reset controller has not probed yet.  In this case, the

> probe of the reset consumer should be deferred.


Thank you for this fix! In the error case, ret was last set by:

        ret = of_alias_get_id(np, "serial");

Depending on device tree alias setup this might return a positive number
or -ENODEV instead of propagating the error value.

> Fixes: e2860e1f62f2 ("serial: 8250_of: Add reset support")

> Cc: stable@vger.kernel.org # v4.13+

> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>


regards
Philipp
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c
index 1e67a7e..160b890 100644
--- a/drivers/tty/serial/8250/8250_of.c
+++ b/drivers/tty/serial/8250/8250_of.c
@@ -136,8 +136,11 @@  static int of_platform_serial_setup(struct platform_device *ofdev,
 	}
 
 	info->rst = devm_reset_control_get_optional_shared(&ofdev->dev, NULL);
-	if (IS_ERR(info->rst))
+	if (IS_ERR(info->rst)) {
+		ret = PTR_ERR(info->rst);
 		goto err_dispose;
+	}
+
 	ret = reset_control_deassert(info->rst);
 	if (ret)
 		goto err_dispose;