[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251225114102.337593-1-alperyasinak1@gmail.com>
Date: Thu, 25 Dec 2025 14:41:00 +0300
From: Alper Ak <alperyasinak1@...il.com>
To: peda@...ntia.se
Cc: Alper Ak <alperyasinak1@...il.com>,
Andrew Davis <afd@...com>,
Krzysztof Kozlowski <krzk@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Thomas Richard (TI.com)" <thomas.richard@...tlin.com>,
Thorsten Blum <thorsten.blum@...ux.dev>,
linux-kernel@...r.kernel.org
Subject: [PATCH] mmux: mmio: fix IS_ERR() vs NULL check for mux_mmio_probe()
devm_kmalloc() returns NULL on failure, not an ERR_PTR value. The
current IS_ERR() check will never catch allocation failures, which
could lead to NULL pointer dereference.
Signed-off-by: Alper Ak <alperyasinak1@...il.com>
---
drivers/mux/mmio.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/mux/mmio.c b/drivers/mux/mmio.c
index e4ddb1e61923..3409af1ffb80 100644
--- a/drivers/mux/mmio.c
+++ b/drivers/mux/mmio.c
@@ -101,13 +101,13 @@ static int mux_mmio_probe(struct platform_device *pdev)
mux_mmio = mux_chip_priv(mux_chip);
mux_mmio->fields = devm_kmalloc(dev, num_fields * sizeof(*mux_mmio->fields), GFP_KERNEL);
- if (IS_ERR(mux_mmio->fields))
- return PTR_ERR(mux_mmio->fields);
+ if (!mux_mmio->fields)
+ return -ENOMEM;
mux_mmio->hardware_states = devm_kmalloc(dev, num_fields *
sizeof(*mux_mmio->hardware_states), GFP_KERNEL);
- if (IS_ERR(mux_mmio->hardware_states))
- return PTR_ERR(mux_mmio->hardware_states);
+ if (!mux_mmio->hardware_states)
+ return -ENOMEM;
for (i = 0; i < num_fields; i++) {
struct mux_control *mux = &mux_chip->mux[i];
--
2.43.0
Powered by blists - more mailing lists