Skip to contentSkip to conversation

ASoC: amd: move the call to devm_kzalloc below platform_get_resource()

PATCH Superseded Defang Bo 2 participants 2 messages Oct 19, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Defang Bo

author
#0 lore raw

PATCH 1/1 ASoC: amd: move the call to devm_kzalloc below platform_get_resource()

Just as the commit <4cb79ef9c6c4>("ASoC: amd: Fix potential NULL pointer dereference"),it makes no sense to allocate any resources if res = platform_get_resource(pdev, IORESOURCE_MEM, 0); fails,so move the call to devm_kzalloc() below the mentioned code.

---
 sound/soc/amd/raven/acp3x-i2s.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
sound/soc/amd/raven/acp3x-i2s.c +3 -5
index a532e01..c9c69eb 100644
@@ -302,16 +302,14 @@ static int acp3x_dai_probe(struct platform_device *pdev)
 	struct i2s_dev_data *adata;
 	int ret;
 
-	adata = devm_kzalloc(&pdev->dev, sizeof(struct i2s_dev_data),
-			GFP_KERNEL);
-	if (!adata)
-		return -ENOMEM;
-
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res) {
 		dev_err(&pdev->dev, "IORESOURCE_MEM FAILED\n");
 		return -ENOMEM;
 	}
+	adata = devm_kzalloc(&pdev->dev, sizeof(struct i2s_dev_data), GFP_KERNEL);
+	if (!adata)
+		return -ENOMEM;
 	adata->acp3x_base = devm_ioremap(&pdev->dev, res->start,
 						resource_size(res));
 	if (!adata->acp3x_base)
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 1 line · Defang Bo

Just as the commit <4cb79ef9c6c4>("ASoC: amd: Fix potential NULL pointer dereference"),it makes no sense to allocate any resources if res = platform_get_resource(pdev, IORESOURCE_MEM, 0); fails,so move the call to devm_kzalloc() below the mentioned code.

Please keep your commit message wrapped at below 80 columns.

sound/soc/amd/raven/acp3x-i2s.c static int acp3x_dai_probe(struct platform_device *pdev) · line 310

Quoted 9 lines
sound/soc/amd/raven/acp3x-i2s.c +1 -3
-	if (!adata)
-		return -ENOMEM;
-
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res) {
 		dev_err(&pdev->dev, "IORESOURCE_MEM FAILED\n");
 		return -ENOMEM;
 	}
+	adata = devm_kzalloc(&pdev->dev, sizeof(struct i2s_dev_data), GFP_KERNEL);

This is missing a blank line between the two code blocks.