mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ASoC: samsung: i2s: check the return value of kstrdup()
@ 2022-02-22 11:53 xkernel.wang
  2022-02-22 12:38 ` Krzysztof Kozlowski
  0 siblings, 1 reply; 2+ messages in thread
From: xkernel.wang @ 2022-02-22 11:53 UTC (permalink / raw)
  To: tiwai, perex
  Cc: krzysztof.kozlowski, s.nawrocki, alsa-devel, linux-kernel, Xiaoke Wang

From: Xiaoke Wang <xkernel.wang@foxmail.com>

kstrdup() is a memory allocation function which can return NULL when
some internal memory errors happen. It is better to check the return
value of it to catch the error in time.

Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
---
 sound/soc/samsung/i2s.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c
index 309badc..70c8271 100644
--- a/sound/soc/samsung/i2s.c
+++ b/sound/soc/samsung/i2s.c
@@ -1349,6 +1349,10 @@ static int i2s_create_secondary_device(struct samsung_i2s_priv *priv)
 		return -ENOMEM;
 
 	pdev_sec->driver_override = kstrdup("samsung-i2s", GFP_KERNEL);
+	if (!pdev_sec->driver_override) {
+		platform_device_put(pdev_sec);
+		return -ENOMEM;
+	}
 
 	ret = platform_device_add(pdev_sec);
 	if (ret < 0) {
-- 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ASoC: samsung: i2s: check the return value of kstrdup()
  2022-02-22 11:53 [PATCH] ASoC: samsung: i2s: check the return value of kstrdup() xkernel.wang
@ 2022-02-22 12:38 ` Krzysztof Kozlowski
  0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Kozlowski @ 2022-02-22 12:38 UTC (permalink / raw)
  To: xkernel.wang, tiwai, perex; +Cc: s.nawrocki, alsa-devel, linux-kernel

On 22/02/2022 12:53, xkernel.wang@foxmail.com wrote:
> From: Xiaoke Wang <xkernel.wang@foxmail.com>
> 
> kstrdup() is a memory allocation function which can return NULL when
> some internal memory errors happen. It is better to check the return
> value of it to catch the error in time.
> 
> Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
> ---
>  sound/soc/samsung/i2s.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>


Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-22 12:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-22 11:53 [PATCH] ASoC: samsung: i2s: check the return value of kstrdup() xkernel.wang
2022-02-22 12:38 ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®