Skip to content

Commit

Permalink
ASoC: samsung: i2s: check the return value of kstrdup()
Browse files Browse the repository at this point in the history
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.

Reviewed-by: Krzysztof Kozlowski <[email protected]>
Signed-off-by: Xiaoke Wang <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
x2018 authored and broonie committed Mar 16, 2022
1 parent a8ae15e commit d39664c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sound/soc/samsung/i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d39664c

Please sign in to comment.