* [PATCH] mmux: mmio: fix IS_ERR() vs NULL check for mux_mmio_probe()
@ 2025-12-25 11:41 Alper Ak
2025-12-25 12:08 ` Krzysztof Kozlowski
0 siblings, 1 reply; 3+ messages in thread
From: Alper Ak @ 2025-12-25 11:41 UTC (permalink / raw)
To: peda
Cc: Alper Ak, Andrew Davis, Krzysztof Kozlowski, Greg Kroah-Hartman,
Thomas Richard (TI.com), Thorsten Blum, linux-kernel
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@gmail.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
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] mmux: mmio: fix IS_ERR() vs NULL check for mux_mmio_probe()
2025-12-25 11:41 [PATCH] mmux: mmio: fix IS_ERR() vs NULL check for mux_mmio_probe() Alper Ak
@ 2025-12-25 12:08 ` Krzysztof Kozlowski
2025-12-25 12:48 ` [PATCH v2] mux: " Alper Ak
0 siblings, 1 reply; 3+ messages in thread
From: Krzysztof Kozlowski @ 2025-12-25 12:08 UTC (permalink / raw)
To: Alper Ak, peda
Cc: Andrew Davis, Greg Kroah-Hartman, Thomas Richard (TI.com),
Thorsten Blum, linux-kernel
On 25/12/2025 12:41, Alper Ak wrote:
> 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@gmail.com>
Missing fixes tag.
> ---
> 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);
I really wonder from where do the people sometimes copy code...
With missing tag:
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] mux: mmio: fix IS_ERR() vs NULL check for mux_mmio_probe()
2025-12-25 12:08 ` Krzysztof Kozlowski
@ 2025-12-25 12:48 ` Alper Ak
0 siblings, 0 replies; 3+ messages in thread
From: Alper Ak @ 2025-12-25 12:48 UTC (permalink / raw)
To: peda
Cc: Alper Ak, Krzysztof Kozlowski, Andrew Davis, Greg Kroah-Hartman,
Thomas Richard (TI.com), Thorsten Blum, linux-kernel
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.
Fixes: 4863cb2b0f50 ("mux: mmio: Add suspend and resume support")
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Alper Ak <alperyasinak1@gmail.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
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-12-25 12:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-25 11:41 [PATCH] mmux: mmio: fix IS_ERR() vs NULL check for mux_mmio_probe() Alper Ak
2025-12-25 12:08 ` Krzysztof Kozlowski
2025-12-25 12:48 ` [PATCH v2] mux: " Alper Ak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox