Commit a19ce320 authored by Bartosz Golaszewski's avatar Bartosz Golaszewski

power: sequencing: fix an invalid pointer dereference in error path

We may end up calling pwrseq_target_free() on a partially initialized
target object whose unit is either NULL or an ERR_PTR(). Avoid
dereferencing invalid memory by adding an appropriate check to
pwrseq_target_free().

Fixes: 249ebf3f ("power: sequencing: implement the pwrseq core")
Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-pm/62a3531e-9927-40f8-b587-254a2dfa47ef@stanley.mountain/Reviewed-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/20240712194004.241939-1-brgl@bgdev.plSigned-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
parent e763c9ec
......@@ -212,7 +212,8 @@ pwrseq_target_new(const struct pwrseq_target_data *data)
static void pwrseq_target_free(struct pwrseq_target *target)
{
pwrseq_unit_put(target->unit);
if (!IS_ERR_OR_NULL(target->unit))
pwrseq_unit_put(target->unit);
kfree_const(target->name);
kfree(target);
}
......
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