Commit a3774e14 authored by Philipp Zabel's avatar Philipp Zabel

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: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
parent 54e991b5
...@@ -138,7 +138,8 @@ EXPORT_SYMBOL_GPL(devm_reset_controller_register); ...@@ -138,7 +138,8 @@ EXPORT_SYMBOL_GPL(devm_reset_controller_register);
*/ */
int reset_control_reset(struct reset_control *rstc) 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; return -EINVAL;
if (rstc->rcdev->ops->reset) if (rstc->rcdev->ops->reset)
...@@ -161,6 +162,9 @@ EXPORT_SYMBOL_GPL(reset_control_reset); ...@@ -161,6 +162,9 @@ EXPORT_SYMBOL_GPL(reset_control_reset);
*/ */
int reset_control_assert(struct reset_control *rstc) int reset_control_assert(struct reset_control *rstc)
{ {
if (WARN_ON(IS_ERR_OR_NULL(rstc)))
return -EINVAL;
if (!rstc->rcdev->ops->assert) if (!rstc->rcdev->ops->assert)
return -ENOTSUPP; return -ENOTSUPP;
...@@ -184,6 +188,9 @@ EXPORT_SYMBOL_GPL(reset_control_assert); ...@@ -184,6 +188,9 @@ EXPORT_SYMBOL_GPL(reset_control_assert);
*/ */
int reset_control_deassert(struct reset_control *rstc) int reset_control_deassert(struct reset_control *rstc)
{ {
if (WARN_ON(IS_ERR_OR_NULL(rstc)))
return -EINVAL;
if (!rstc->rcdev->ops->deassert) if (!rstc->rcdev->ops->deassert)
return -ENOTSUPP; return -ENOTSUPP;
...@@ -204,6 +211,9 @@ EXPORT_SYMBOL_GPL(reset_control_deassert); ...@@ -204,6 +211,9 @@ EXPORT_SYMBOL_GPL(reset_control_deassert);
*/ */
int reset_control_status(struct reset_control *rstc) int reset_control_status(struct reset_control *rstc)
{ {
if (WARN_ON(IS_ERR_OR_NULL(rstc)))
return -EINVAL;
if (rstc->rcdev->ops->status) if (rstc->rcdev->ops->status)
return rstc->rcdev->ops->status(rstc->rcdev, rstc->id); return rstc->rcdev->ops->status(rstc->rcdev, rstc->id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment