Skip to contentSkip to conversation

PCI/bwctrl: Check for error code from devm_mutex_init() call

PATCH Superseded Andy Shevchenko 2 participants 3 messages Oct 30, 2024 – Oct 31, 2024

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI/bwctrl: Check for error code from devm_mutex_init() call

Even if it's not critical, the avoidance of checking the error code from devm_mutex_init() call today diminishes the point of using devm variant of it. Tomorrow it may even leak something. Add the missed check.

Fixes 9b3da6e19e4d ("PCI/bwctrl: Add pcie_set_target_speed() to set PCIe Link Speed")
---
 drivers/pci/pcie/bwctrl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/pci/pcie/bwctrl.c +4 -1
index 3a93ed0550c7..2a19e441a901 100644
@@ -299,7 +299,10 @@ static int pcie_bwnotif_probe(struct pcie_device *srv)
 	if (!data)
 		return -ENOMEM;
 
-	devm_mutex_init(&srv->device, &data->set_speed_mutex);
+	ret = devm_mutex_init(&srv->device, &data->set_speed_mutex);
+	if (ret)
+		return ret;
+
 	ret = devm_request_threaded_irq(&srv->device, srv->irq, NULL,
 					pcie_bwnotif_irq_thread,
 					IRQF_SHARED | IRQF_ONESHOT,
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
#1 lore raw
Quoted 7 lines · Andy Shevchenko

Even if it's not critical, the avoidance of checking the error code from devm_mutex_init() call today diminishes the point of using devm variant of it. Tomorrow it may even leak something. Add the missed check.

Fixes 9b3da6e19e4d ("PCI/bwctrl: Add pcie_set_target_speed() to set PCIe Link Speed")

Squashed into 399ba413fa23 ("PCI/bwctrl: Add pcie_set_target_speed() to set PCIe Link Speed"), thanks, Andy.

Quoted 23 lines
---
 drivers/pci/pcie/bwctrl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/pci/pcie/bwctrl.c +4 -1
index 3a93ed0550c7..2a19e441a901 100644
@@ -299,7 +299,10 @@ static int pcie_bwnotif_probe(struct pcie_device *srv)
 	if (!data)
 		return -ENOMEM;
 
-	devm_mutex_init(&srv->device, &data->set_speed_mutex);
+	ret = devm_mutex_init(&srv->device, &data->set_speed_mutex);
+	if (ret)
+		return ret;
+
 	ret = devm_request_threaded_irq(&srv->device, srv->irq, NULL,
 					pcie_bwnotif_irq_thread,
 					IRQF_SHARED | IRQF_ONESHOT,
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
#2 lore raw
Quoted 11 lines · Bjorn Helgaas
Quoted 7 lines · Andy Shevchenko

Even if it's not critical, the avoidance of checking the error code from devm_mutex_init() call today diminishes the point of using devm variant of it. Tomorrow it may even leak something. Add the missed check.

Fixes 9b3da6e19e4d ("PCI/bwctrl: Add pcie_set_target_speed() to set PCIe Link Speed")

Squashed into 399ba413fa23 ("PCI/bwctrl: Add pcie_set_target_speed() to set PCIe Link Speed"), thanks, Andy.

Thanks, that works for me!

Signature · 2 lines
With Best Regards,
Andy Shevchenko