diff options
author | Philipp Zabel <p.zabel@pengutronix.de> | 2016-06-20 13:05:14 +0200 |
---|---|---|
committer | Philipp Zabel <p.zabel@pengutronix.de> | 2016-08-24 15:21:36 +0200 |
commit | a3774e146a14a78e4dc84b28e841f3e91a29c6e4 (patch) | |
tree | ea53600a171286c660dfac46959d1854c4a2e3df /drivers/reset | |
parent | reset: uniphier: add reset controller driver for UniPhier SoCs (diff) | |
download | linux-a3774e146a14a78e4dc84b28e841f3e91a29c6e4.tar.xz linux-a3774e146a14a78e4dc84b28e841f3e91a29c6e4.zip |
reset: warn on invalid input to reset_control_reset/assert/deassert/status
Instead of potentially crashing, dump a backtrace and return -EINVAL if
rstc is NULL or an error code.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Diffstat (limited to 'drivers/reset')
-rw-r--r-- | drivers/reset/core.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/reset/core.c b/drivers/reset/core.c index 395dc9ce492e..b8ae1dbd4c17 100644 --- a/drivers/reset/core.c +++ b/drivers/reset/core.c @@ -138,7 +138,8 @@ EXPORT_SYMBOL_GPL(devm_reset_controller_register); */ int reset_control_reset(struct reset_control *rstc) { - if (WARN_ON(rstc->shared)) + if (WARN_ON(IS_ERR_OR_NULL(rstc)) || + WARN_ON(rstc->shared)) return -EINVAL; if (rstc->rcdev->ops->reset) @@ -161,6 +162,9 @@ EXPORT_SYMBOL_GPL(reset_control_reset); */ int reset_control_assert(struct reset_control *rstc) { + if (WARN_ON(IS_ERR_OR_NULL(rstc))) + return -EINVAL; + if (!rstc->rcdev->ops->assert) return -ENOTSUPP; @@ -184,6 +188,9 @@ EXPORT_SYMBOL_GPL(reset_control_assert); */ int reset_control_deassert(struct reset_control *rstc) { + if (WARN_ON(IS_ERR_OR_NULL(rstc))) + return -EINVAL; + if (!rstc->rcdev->ops->deassert) return -ENOTSUPP; @@ -204,6 +211,9 @@ EXPORT_SYMBOL_GPL(reset_control_deassert); */ int reset_control_status(struct reset_control *rstc) { + if (WARN_ON(IS_ERR_OR_NULL(rstc))) + return -EINVAL; + if (rstc->rcdev->ops->status) return rstc->rcdev->ops->status(rstc->rcdev, rstc->id); |