Skip to contentSkip to conversation

ASoC: samsung: i2s: Fix return value check in i2s_create_secondary_device()

PATCH In review Wei Yongjun 3 participants 3 messages Feb 16, 2019 – Feb 18, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: samsung: i2s: Fix return value check in i2s_create_secondary_device()

In case of error, the function platform_device_register_simple() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().

Fixes 7196c64c7d0c ("ASoC: samsung: i2s: Restore support for the secondary PCM")
---
 sound/soc/samsung/i2s.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/samsung/i2s.c +2 -2
index 72f0cb7abb30..15844c00c3cd 100644
@@ -1342,8 +1342,8 @@ static int i2s_create_secondary_device(struct samsung_i2s_priv *priv)
 	int ret;
 
 	pdev = platform_device_register_simple("samsung-i2s-sec", -1, NULL, 0);
-	if (!pdev)
-		return -ENOMEM;
+	if (IS_ERR(pdev))
+		return PTR_ERR(pdev);
 
 	ret = device_attach(&pdev->dev);
 	if (ret < 0) {
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Wei Yongjun

In case of error, the function platform_device_register_simple() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().

Fixes 7196c64c7d0c ("ASoC: samsung: i2s: Restore support for the secondary PCM")
---
 sound/soc/samsung/i2s.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Best regards,
Krzysztof

#2 lore raw
In reply to Wei Yongjun
Quoted 3 lines · Wei Yongjun

In case of error, the function platform_device_register_simple() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().

Thanks for the patch, it looks good but I have already prepared other fix that removes the platform_device_register_simple() call entirely:

"ASoC: samsung: i2s: Fix multiple "IIS multi" devices initialization"
https://www.spinics.net/lists/kernel/msg3045092.html

Signature · 2 lines
Thanks,
Sylwester