* [PATCH 0/2] mfd: ls2kbmc: Fix a couple Smatch warnings
@ 2025-10-03 9:28 Dan Carpenter
2025-10-03 9:29 ` [PATCH 1/2] mfd: ls2kbmc: Fix an IS_ERR() vs NULL check in probe() Dan Carpenter
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Dan Carpenter @ 2025-10-03 9:28 UTC (permalink / raw)
To: Binbin Zhou
Cc: Chong Qiao, Corey Minyard, Huacai Chen, Lee Jones, linux-kernel
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(-)
--
2.51.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] mfd: ls2kbmc: Fix an IS_ERR() vs NULL check in probe()
2025-10-03 9:28 [PATCH 0/2] mfd: ls2kbmc: Fix a couple Smatch warnings Dan Carpenter
@ 2025-10-03 9:29 ` Dan Carpenter
2025-10-03 9:29 ` [PATCH 2/2] mfd: ls2kbmc: check for devm_mfd_add_devices() failure Dan Carpenter
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2025-10-03 9:29 UTC (permalink / raw)
To: Binbin Zhou
Cc: Chong Qiao, Lee Jones, Huacai Chen, Corey Minyard, linux-kernel
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")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/mfd/ls2k-bmc-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mfd/ls2k-bmc-core.c b/drivers/mfd/ls2k-bmc-core.c
index e162b3c7c9f8..5f38514fa89e 100644
--- a/drivers/mfd/ls2k-bmc-core.c
+++ b/drivers/mfd/ls2k-bmc-core.c
@@ -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;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] mfd: ls2kbmc: check for devm_mfd_add_devices() failure
2025-10-03 9:28 [PATCH 0/2] mfd: ls2kbmc: Fix a couple Smatch warnings Dan Carpenter
2025-10-03 9:29 ` [PATCH 1/2] mfd: ls2kbmc: Fix an IS_ERR() vs NULL check in probe() Dan Carpenter
@ 2025-10-03 9:29 ` Dan Carpenter
2025-10-03 15:38 ` [PATCH 0/2] mfd: ls2kbmc: Fix a couple Smatch warnings Corey Minyard
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2025-10-03 9:29 UTC (permalink / raw)
To: Binbin Zhou
Cc: Chong Qiao, Lee Jones, Corey Minyard, Huacai Chen, linux-kernel
Call pci_disable_device() if devm_mfd_add_devices() fails.
Fixes: 0d64f6d1ffe9 ("mfd: ls2kbmc: Introduce Loongson-2K BMC core driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/mfd/ls2k-bmc-core.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/mfd/ls2k-bmc-core.c b/drivers/mfd/ls2k-bmc-core.c
index 5f38514fa89e..69387dad6661 100644
--- a/drivers/mfd/ls2k-bmc-core.c
+++ b/drivers/mfd/ls2k-bmc-core.c
@@ -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);
--
2.51.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] mfd: ls2kbmc: Fix a couple Smatch warnings
2025-10-03 9:28 [PATCH 0/2] mfd: ls2kbmc: Fix a couple Smatch warnings Dan Carpenter
2025-10-03 9:29 ` [PATCH 1/2] mfd: ls2kbmc: Fix an IS_ERR() vs NULL check in probe() Dan Carpenter
2025-10-03 9:29 ` [PATCH 2/2] mfd: ls2kbmc: check for devm_mfd_add_devices() failure Dan Carpenter
@ 2025-10-03 15:38 ` Corey Minyard
2025-10-08 14:03 ` Lee Jones
2025-10-09 3:07 ` Huacai Chen
2025-10-09 10:01 ` Lee Jones
4 siblings, 1 reply; 8+ messages in thread
From: Corey Minyard @ 2025-10-03 15:38 UTC (permalink / raw)
To: Dan Carpenter
Cc: Binbin Zhou, Chong Qiao, Huacai Chen, Lee Jones, linux-kernel
On Fri, Oct 03, 2025 at 12:28:58PM +0300, Dan Carpenter wrote:
> 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
>
> drivers/mfd/ls2k-bmc-core.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> --
> 2.51.0
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] mfd: ls2kbmc: Fix a couple Smatch warnings
2025-10-03 15:38 ` [PATCH 0/2] mfd: ls2kbmc: Fix a couple Smatch warnings Corey Minyard
@ 2025-10-08 14:03 ` Lee Jones
2025-10-09 9:56 ` Lee Jones
0 siblings, 1 reply; 8+ messages in thread
From: Lee Jones @ 2025-10-08 14:03 UTC (permalink / raw)
To: Corey Minyard
Cc: Dan Carpenter, Binbin Zhou, Chong Qiao, Huacai Chen, linux-kernel
On Fri, 03 Oct 2025, Corey Minyard wrote:
> On Fri, Oct 03, 2025 at 12:28:58PM +0300, Dan Carpenter wrote:
> > 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.
Do what, now?
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] mfd: ls2kbmc: Fix a couple Smatch warnings
2025-10-03 9:28 [PATCH 0/2] mfd: ls2kbmc: Fix a couple Smatch warnings Dan Carpenter
` (2 preceding siblings ...)
2025-10-03 15:38 ` [PATCH 0/2] mfd: ls2kbmc: Fix a couple Smatch warnings Corey Minyard
@ 2025-10-09 3:07 ` Huacai Chen
2025-10-09 10:01 ` Lee Jones
4 siblings, 0 replies; 8+ messages in thread
From: Huacai Chen @ 2025-10-09 3:07 UTC (permalink / raw)
To: Dan Carpenter
Cc: Binbin Zhou, Chong Qiao, Corey Minyard, Lee Jones, linux-kernel
On Fri, Oct 3, 2025 at 5:29 PM Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> 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.
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
>
> 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
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] mfd: ls2kbmc: Fix a couple Smatch warnings
2025-10-08 14:03 ` Lee Jones
@ 2025-10-09 9:56 ` Lee Jones
0 siblings, 0 replies; 8+ messages in thread
From: Lee Jones @ 2025-10-09 9:56 UTC (permalink / raw)
To: Corey Minyard
Cc: Dan Carpenter, Binbin Zhou, Chong Qiao, Huacai Chen, linux-kernel
On Wed, 08 Oct 2025, Lee Jones wrote:
> On Fri, 03 Oct 2025, Corey Minyard wrote:
>
> > On Fri, Oct 03, 2025 at 12:28:58PM +0300, Dan Carpenter wrote:
> > > 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.
>
> 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.
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] mfd: ls2kbmc: Fix a couple Smatch warnings
2025-10-03 9:28 [PATCH 0/2] mfd: ls2kbmc: Fix a couple Smatch warnings Dan Carpenter
` (3 preceding siblings ...)
2025-10-09 3:07 ` Huacai Chen
@ 2025-10-09 10:01 ` Lee Jones
4 siblings, 0 replies; 8+ messages in thread
From: Lee Jones @ 2025-10-09 10:01 UTC (permalink / raw)
To: Binbin Zhou, Dan Carpenter
Cc: Chong Qiao, Corey Minyard, Huacai Chen, Lee Jones, linux-kernel
On Fri, 03 Oct 2025 12:28:58 +0300, Dan Carpenter wrote:
> 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 [李琼斯]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-10-09 10:01 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-03 9:28 [PATCH 0/2] mfd: ls2kbmc: Fix a couple Smatch warnings Dan Carpenter
2025-10-03 9:29 ` [PATCH 1/2] mfd: ls2kbmc: Fix an IS_ERR() vs NULL check in probe() Dan Carpenter
2025-10-03 9:29 ` [PATCH 2/2] mfd: ls2kbmc: check for devm_mfd_add_devices() failure Dan Carpenter
2025-10-03 15:38 ` [PATCH 0/2] mfd: ls2kbmc: Fix a couple Smatch warnings Corey Minyard
2025-10-08 14:03 ` Lee Jones
2025-10-09 9:56 ` Lee Jones
2025-10-09 3:07 ` Huacai Chen
2025-10-09 10:01 ` Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox