diff mbox series

[v3,16/20] ASoC: hdac_hdmi: use devm_kmemdup_array()

Message ID 20250203080902.1864382-17-raag.jadav@intel.com (mailing list archive)
State New
Headers show
Series Split devres APIs to device/devres.h and introduce devm_kmemdup_array() | expand

Commit Message

Raag Jadav Feb. 3, 2025, 8:08 a.m. UTC
Convert to use devm_kmemdup_array() which is more robust.

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
 sound/soc/codecs/hdac_hdmi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Andy Shevchenko Feb. 3, 2025, 9:52 a.m. UTC | #1
On Mon, Feb 03, 2025 at 01:38:58PM +0530, Raag Jadav wrote:
> Convert to use devm_kmemdup_array() which is more robust.

...

> -	se->texts = devm_kmemdup(&hdev->dev, items,
> -			(num_items  * sizeof(char *)), GFP_KERNEL);
> +	se->texts = devm_kmemdup_array(&hdev->dev, items, num_items, sizeof(char *), GFP_KERNEL);

In similar way, sizeof(*se->texts) ?

>  	if (!se->texts)
>  		return -ENOMEM;
diff mbox series

Patch

diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index e1a7f0b0c0f3..a0f305a8fbf9 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -1017,8 +1017,7 @@  static int hdac_hdmi_create_pin_port_muxs(struct hdac_device *hdev,
 			return -ENOMEM;
 	}
 
-	se->texts = devm_kmemdup(&hdev->dev, items,
-			(num_items  * sizeof(char *)), GFP_KERNEL);
+	se->texts = devm_kmemdup_array(&hdev->dev, items, num_items, sizeof(char *), GFP_KERNEL);
 	if (!se->texts)
 		return -ENOMEM;