[PATCH] mux: mmio: Zero the allocated memory

Krzysztof Kozlowski posted 1 patch 1 month, 2 weeks ago
There is a newer version of this series
drivers/mux/mmio.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
[PATCH] mux: mmio: Zero the allocated memory
Posted by Krzysztof Kozlowski 1 month, 2 weeks ago
Zero the allocated memory in probe() for fields and states for increased
code safety and to match expected Linux coding style.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>

---

Cc: Alper Ak <alperyasinak1@gmail.com>
Dependency - context rebased on top of:
https://patch.msgid.link/20251225114102.337593-1-alperyasinak1@gmail.com
---
 drivers/mux/mmio.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/mux/mmio.c b/drivers/mux/mmio.c
index 3409af1ffb80..0bd58eefb14a 100644
--- a/drivers/mux/mmio.c
+++ b/drivers/mux/mmio.c
@@ -100,12 +100,14 @@ 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);
+	mux_mmio->fields = devm_kcalloc(dev, num_fields, sizeof(*mux_mmio->fields),
+					GFP_KERNEL);
 	if (!mux_mmio->fields)
 		return -ENOMEM;
 
-	mux_mmio->hardware_states = devm_kmalloc(dev, num_fields *
-						 sizeof(*mux_mmio->hardware_states), GFP_KERNEL);
+	mux_mmio->hardware_states = devm_kcalloc(dev, num_fields,
+						 sizeof(*mux_mmio->hardware_states),
+						 GFP_KERNEL);
 	if (!mux_mmio->hardware_states)
 		return -ENOMEM;
 
-- 
2.51.0
Re: [PATCH] mux: mmio: Zero the allocated memory
Posted by Krzysztof Kozlowski 1 month, 2 weeks ago
On 25/12/2025 13:15, Krzysztof Kozlowski wrote:
> Zero the allocated memory in probe() for fields and states for increased
> code safety and to match expected Linux coding style.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
> 
> ---
> 
> Cc: Alper Ak <alperyasinak1@gmail.com>
> Dependency - context rebased on top of:
> https://patch.msgid.link/20251225114102.337593-1-alperyasinak1@gmail.com

Please ignore this one, that's too fast fingers. :(

Best regards,
Krzysztof