mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 22:14:03 +02:00
power: sequencing: fix NULL-pointer dereference in pwrseq_device_register()
If dev_set_name() fails in pwrseq_device_register(), we jump to the
err_put_pwrseq label before initializing pwrseq->targets.
pwrseq_release() will try to iterate over targets unconditionally and
subsequently dereference an invalid pointer. Move the call to
dev_set_name() after the list head is initialized.
Fixes: 249ebf3f65 ("power: sequencing: implement the pwrseq core")
Cc: stable@vger.kernel.org
Reported-by: sashiko-bot <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260903-pwrseq-kunit-v1-0-1f893d2cabc2%40oss.qualcomm.com?part=2
Link: https://patch.msgid.link/20260909-pwrseq-kunit-v2-3-ef496afc89d2@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
This commit is contained in:
parent
115b303e8e
commit
242da4318d
|
|
@ -505,10 +505,6 @@ pwrseq_device_register(const struct pwrseq_config *config)
|
|||
*/
|
||||
device_initialize(&pwrseq->dev);
|
||||
|
||||
ret = dev_set_name(&pwrseq->dev, "pwrseq.%d", pwrseq->id);
|
||||
if (ret)
|
||||
goto err_put_pwrseq;
|
||||
|
||||
pwrseq->owner = config->owner ?: THIS_MODULE;
|
||||
pwrseq->match = config->match;
|
||||
|
||||
|
|
@ -517,6 +513,10 @@ pwrseq_device_register(const struct pwrseq_config *config)
|
|||
INIT_LIST_HEAD(&pwrseq->targets);
|
||||
INIT_LIST_HEAD(&pwrseq->units);
|
||||
|
||||
ret = dev_set_name(&pwrseq->dev, "pwrseq.%d", pwrseq->id);
|
||||
if (ret)
|
||||
goto err_put_pwrseq;
|
||||
|
||||
ret = pwrseq_setup_targets(config->targets, pwrseq);
|
||||
if (ret)
|
||||
goto err_put_pwrseq;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user