Merge tag 'pwrseq-fixes-for-v7.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux

Pull power sequencing fixes from Bartosz Golaszewski:

 - fix a use-after-free bug and a serdev reference leak in pwrseq-pcie-m2

 - increase WCN7850 power-up delay in pwrseq-qcom-wcn

 - make the API contract for pwrseq descriptor serialization clearer

* tag 'pwrseq-fixes-for-v7.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux:
  power: sequencing: pcie-m2: fix serdev controller reference leak
  power: sequencing: pcie-m2: use devm_mutex_init()
  power: sequencing: pcie-m2: fix use-after-free in pwrseq_pcie_m2_vregs_enable()
  power: sequencing: core: add a note on descriptor serialization
  power: sequencing: qcom-wcn: increase WCN7850 power-up delay
This commit is contained in:
Linus Torvalds
2026-11-12 10:26:32 -08:00
3 changed files with 34 additions and 36 deletions
+5
View File
@@ -270,6 +270,11 @@ static void pwrseq_device_put(struct pwrseq_device *pwrseq)
* @target: Reference to the target this descriptor allows to control.
* @powered_on: Power state set by the holder of the descriptor (not necessarily
* corresponding to the actual power state of the device).
*
* Note: The user that requested the descriptor from the provider is
* responsible for the serialization of access to it. Concurrent threads must
* not access the descriptor structure without synchronization as power
* sequencing core does not provide any per-descriptor locking.
*/
struct pwrseq_desc {
struct pwrseq_device *pwrseq;
+28 -35
View File
@@ -296,7 +296,7 @@ static int pwrseq_pcie_m2_create_serdev_one(struct pwrseq_pcie_m2_ctx *ctx,
struct serdev_controller *serdev_ctrl;
struct device *dev = ctx->dev;
struct pwrseq_pci_dev *pci_dev;
int ret;
int ret = 0;
struct device_node *serdev_parent __free(device_node) =
of_graph_get_remote_node(dev_of_node(ctx->dev), 3, 0);
@@ -308,16 +308,14 @@ static int pwrseq_pcie_m2_create_serdev_one(struct pwrseq_pcie_m2_ctx *ctx,
return 0;
/* Bail out if the device was already attached to this controller */
if (serdev_ctrl->serdev) {
serdev_controller_put(serdev_ctrl);
return 0;
}
if (serdev_ctrl->serdev)
goto err_put_ctrl;
/* Bail out if the serdev device was already created for the PCI dev */
scoped_guard(mutex, &ctx->list_lock) {
list_for_each_entry(pci_dev, &ctx->pci_devices, list) {
if (pci_dev->pdev == pdev)
return 0;
goto err_put_ctrl;
}
}
@@ -533,6 +531,14 @@ err_remove_serdev:
return ret;
}
static void pwrseq_pcie_m2_free_regulators(void *data)
{
struct pwrseq_pcie_m2_ctx *ctx = data;
regulator_bulk_free(ctx->num_vregs, ctx->regs);
kfree(ctx->regs);
}
static int pwrseq_pcie_m2_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -563,19 +569,19 @@ static int pwrseq_pcie_m2_probe(struct platform_device *pdev)
ctx->num_vregs = ret;
ret = devm_add_action_or_reset(dev, pwrseq_pcie_m2_free_regulators, ctx);
if (ret)
return ret;
ctx->w_disable1_gpio = devm_gpiod_get_optional(dev, "w-disable1", GPIOD_OUT_HIGH);
if (IS_ERR(ctx->w_disable1_gpio)) {
ret = dev_err_probe(dev, PTR_ERR(ctx->w_disable1_gpio),
if (IS_ERR(ctx->w_disable1_gpio))
return dev_err_probe(dev, PTR_ERR(ctx->w_disable1_gpio),
"Failed to get the W_DISABLE_1# GPIO\n");
goto err_free_regulators;
}
ctx->w_disable2_gpio = devm_gpiod_get_optional(dev, "w-disable2", GPIOD_OUT_HIGH);
if (IS_ERR(ctx->w_disable2_gpio)) {
ret = dev_err_probe(dev, PTR_ERR(ctx->w_disable2_gpio),
if (IS_ERR(ctx->w_disable2_gpio))
return dev_err_probe(dev, PTR_ERR(ctx->w_disable2_gpio),
"Failed to get the W_DISABLE_2# GPIO\n");
goto err_free_regulators;
}
config.parent = dev;
config.owner = THIS_MODULE;
@@ -584,20 +590,21 @@ static int pwrseq_pcie_m2_probe(struct platform_device *pdev)
config.targets = ctx->pdata->targets;
ctx->pwrseq = devm_pwrseq_device_register(dev, &config);
if (IS_ERR(ctx->pwrseq)) {
ret = dev_err_probe(dev, PTR_ERR(ctx->pwrseq),
if (IS_ERR(ctx->pwrseq))
return dev_err_probe(dev, PTR_ERR(ctx->pwrseq),
"Failed to register the power sequencer\n");
goto err_free_regulators;
}
mutex_init(&ctx->list_lock);
ret = devm_mutex_init(dev, &ctx->list_lock);
if (ret)
return ret;
INIT_LIST_HEAD(&ctx->pci_devices);
ctx->dev = dev;
/* Create serdev for available PCI devices (if required) */
ret = pwrseq_pcie_m2_create_serdev(ctx);
if (ret)
goto err_destroy_mutex;
return ret;
/*
* Register a notifier for creating protocol devices for
@@ -605,17 +612,7 @@ static int pwrseq_pcie_m2_probe(struct platform_device *pdev)
*/
ret = pwrseq_pcie_m2_register_notifier(ctx);
if (ret)
goto err_remove_serdev;
return 0;
err_remove_serdev:
pwrseq_pcie_m2_remove_serdev(ctx, NULL);
err_destroy_mutex:
mutex_destroy(&ctx->list_lock);
err_free_regulators:
regulator_bulk_free(ctx->num_vregs, ctx->regs);
kfree(ctx->regs);
pwrseq_pcie_m2_remove_serdev(ctx, NULL);
return ret;
}
@@ -626,10 +623,6 @@ static void pwrseq_pcie_m2_remove(struct platform_device *pdev)
bus_unregister_notifier(&pci_bus_type, &ctx->nb);
pwrseq_pcie_m2_remove_serdev(ctx, NULL);
mutex_destroy(&ctx->list_lock);
regulator_bulk_free(ctx->num_vregs, ctx->regs);
kfree(ctx->regs);
}
static const struct of_device_id pwrseq_pcie_m2_of_match[] = {
+1 -1
View File
@@ -427,7 +427,7 @@ static const char *const pwrseq_wcn7850_vregs[] = {
static const struct pwrseq_qcom_wcn_pdata pwrseq_wcn7850_of_data = {
.vregs = pwrseq_wcn7850_vregs,
.num_vregs = ARRAY_SIZE(pwrseq_wcn7850_vregs),
.pwup_delay_ms = 50,
.pwup_delay_ms = 100,
.targets = pwrseq_qcom_wcn_targets,
};