Skip to contentSkip to conversation

mfd: ls2kbmc: Fix a couple Smatch warnings

PATCH Applied Dan Carpenter 4 participants 8 messages Oct 3, 2025 – Oct 9, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover mfd: ls2kbmc: Fix a couple Smatch warnings

These are two issues which were detected by Smatch. They're not really going to happen in real life. Small kmalloc()s can't fail. The devm_mfd_add_devices() function isn't going to fail either...

But still, they're worth fixing just for correctness sake.

Dan Carpenter (2):
mfd: ls2kbmc: Fix an IS_ERR() vs NULL check in probe()
mfd: ls2kbmc: check for devm_mfd_add_devices() failure

 drivers/mfd/ls2k-bmc-core.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
Signature · 1 line
2.51.0
#1 lore raw

PATCH 1/2 mfd: ls2kbmc: Fix an IS_ERR() vs NULL check in probe()

The devm_kzalloc() function returns NULL on error so check for that instead of error pointers.

Fixes d952bba3fbb5 ("mfd: ls2kbmc: Add Loongson-2K BMC reset function support")
---
 drivers/mfd/ls2k-bmc-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/ls2k-bmc-core.c +1 -1
index e162b3c7c9f8..5f38514fa89e 100644
@@ -469,7 +469,7 @@ static int ls2k_bmc_probe(struct pci_dev *dev, const struct pci_device_id *id)
 		return ret;
 
 	ddata = devm_kzalloc(&dev->dev, sizeof(*ddata), GFP_KERNEL);
-	if (IS_ERR(ddata)) {
+	if (!ddata) {
 		ret = -ENOMEM;
 		goto disable_pci;
 	}
Signature · 1 line
2.51.0
#2 lore raw

PATCH 2/2 mfd: ls2kbmc: check for devm_mfd_add_devices() failure

In reply to Dan Carpenter

Call pci_disable_device() if devm_mfd_add_devices() fails.

Fixes 0d64f6d1ffe9 ("mfd: ls2kbmc: Introduce Loongson-2K BMC core driver")
---
 drivers/mfd/ls2k-bmc-core.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/mfd/ls2k-bmc-core.c +7 -3
index 5f38514fa89e..69387dad6661 100644
@@ -495,9 +495,13 @@ static int ls2k_bmc_probe(struct pci_dev *dev, const struct pci_device_id *id)
 		goto disable_pci;
 	}
 
-	return devm_mfd_add_devices(&dev->dev, PLATFORM_DEVID_AUTO,
-				    ls2k_bmc_cells, ARRAY_SIZE(ls2k_bmc_cells),
-				    &dev->resource[0], 0, NULL);
+	ret = devm_mfd_add_devices(&dev->dev, PLATFORM_DEVID_AUTO,
+				   ls2k_bmc_cells, ARRAY_SIZE(ls2k_bmc_cells),
+				   &dev->resource[0], 0, NULL);
+	if (ret)
+		goto disable_pci;
+
+	return 0;
 
 disable_pci:
 	pci_disable_device(dev);
Signature · 1 line
2.51.0
#3 lore raw
In reply to Dan Carpenter
Quoted 9 lines · Dan Carpenter

These are two issues which were detected by Smatch. They're not really going to happen in real life. Small kmalloc()s can't fail. The devm_mfd_add_devices() function isn't going to fail either...

But still, they're worth fixing just for correctness sake.

Dan Carpenter (2):
mfd: ls2kbmc: Fix an IS_ERR() vs NULL check in probe()
mfd: ls2kbmc: check for devm_mfd_add_devices() failure

Got them, thank you. I'll get this in for 6.18.

-corey

Quoted 7 lines
 drivers/mfd/ls2k-bmc-core.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
Signature · 1 line
2.51.0
maintainer
#4 lore raw
Quoted 5 lines · Corey Minyard
Quoted 4 lines · Dan Carpenter

These are two issues which were detected by Smatch. They're not really going to happen in real life. Small kmalloc()s can't fail. The devm_mfd_add_devices() function isn't going to fail either...

Quoted 7 lines
Quoted 5 lines

But still, they're worth fixing just for correctness sake.

Dan Carpenter (2):
mfd: ls2kbmc: Fix an IS_ERR() vs NULL check in probe()
mfd: ls2kbmc: check for devm_mfd_add_devices() failure

Got them, thank you. I'll get this in for 6.18.

Do what, now?

Signature · 1 line
Lee Jones [李琼斯]
maintainer
#5 lore raw
Quoted 9 lines · Lee Jones
Quoted 7 lines · Corey Minyard
Quoted 6 lines · Dan Carpenter

These are two issues which were detected by Smatch. They're not really going to happen in real life. Small kmalloc()s can't fail. The devm_mfd_add_devices() function isn't going to fail either...

But still, they're worth fixing just for correctness sake.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Dan Carpenter (2):
mfd: ls2kbmc: Fix an IS_ERR() vs NULL check in probe()
mfd: ls2kbmc: check for devm_mfd_add_devices() failure

Got them, thank you. I'll get this in for 6.18.

Do what, now?

Corey, can you remove these from your IPMI tree please.

They are in the incorrect format and are not yours to collect.

Signature · 1 line
Lee Jones [李琼斯]
Reviewed-by on the v1 series
#6 lore raw
In reply to Dan Carpenter
Quoted 6 lines · Dan Carpenter

These are two issues which were detected by Smatch. They're not really going to happen in real life. Small kmalloc()s can't fail. The devm_mfd_add_devices() function isn't going to fail either...

But still, they're worth fixing just for correctness sake.

Quoted 11 lines

Dan Carpenter (2):
mfd: ls2kbmc: Fix an IS_ERR() vs NULL check in probe()
mfd: ls2kbmc: check for devm_mfd_add_devices() failure

 drivers/mfd/ls2k-bmc-core.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

--
2.51.0

maintainer Applied
#7 lore raw
In reply to Dan Carpenter
Quoted 11 lines · Dan Carpenter

These are two issues which were detected by Smatch. They're not really going to happen in real life. Small kmalloc()s can't fail. The devm_mfd_add_devices() function isn't going to fail either...

But still, they're worth fixing just for correctness sake.

Dan Carpenter (2):
mfd: ls2kbmc: Fix an IS_ERR() vs NULL check in probe()
mfd: ls2kbmc: check for devm_mfd_add_devices() failure

[...]

Applied, thanks!

[1/2] mfd: ls2kbmc: Fix an IS_ERR() vs NULL check in probe()

      commit: b9be0a544c0684672168c7d4a95dc54ba8e1e883
[2/2] mfd: ls2kbmc: check for devm_mfd_add_devices() failure
      commit: 35fc7b7df6761233e9d1f85cfc7fc5c4372a5d7b

--
Lee Jones [李琼斯]