Skip to content

Commit a19ce32

Browse files
author
Bartosz Golaszewski
committed
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: 249ebf3 ("power: sequencing: implement the pwrseq core") Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Closes: https://lore.kernel.org/linux-pm/62a3531e-9927-40f8-b587-254a2dfa47ef@stanley.mountain/ Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org> Link: https://lore.kernel.org/r/20240712194004.241939-1-brgl@bgdev.pl Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
1 parent e763c9e commit a19ce32

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • drivers/power/sequencing

drivers/power/sequencing/core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ pwrseq_target_new(const struct pwrseq_target_data *data)
212212

213213
static void pwrseq_target_free(struct pwrseq_target *target)
214214
{
215-
pwrseq_unit_put(target->unit);
215+
if (!IS_ERR_OR_NULL(target->unit))
216+
pwrseq_unit_put(target->unit);
216217
kfree_const(target->name);
217218
kfree(target);
218219
}

0 commit comments

Comments
 (0)