Skip to content

Commit

Permalink
ASoC: imx-card: Add NULL check in imx_card_probe()
Browse files Browse the repository at this point in the history
devm_kasprintf() returns NULL when memory allocation fails. Currently,
imx_card_probe() does not check for this case, which results in a NULL
pointer dereference.

Add NULL check after devm_kasprintf() to prevent this issue.

Fixes: aa73670 ("ASoC: imx-card: Add imx-card machine driver")
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20250401142510.29900-1-bsdhenrymartin@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Henry Martin authored and Mark Brown committed Apr 1, 2025
1 parent cc80b44 commit 93d3460
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sound/soc/fsl/imx-card.c
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,8 @@ static int imx_card_probe(struct platform_device *pdev)
data->dapm_routes[i].sink =
devm_kasprintf(&pdev->dev, GFP_KERNEL, "%d %s",
i + 1, "Playback");
if (!data->dapm_routes[i].sink)
return -ENOMEM;
data->dapm_routes[i].source = "CPU-Playback";
}
}
Expand All @@ -789,6 +791,8 @@ static int imx_card_probe(struct platform_device *pdev)
data->dapm_routes[i].source =
devm_kasprintf(&pdev->dev, GFP_KERNEL, "%d %s",
i + 1, "Capture");
if (!data->dapm_routes[i].source)
return -ENOMEM;
data->dapm_routes[i].sink = "CPU-Capture";
}
}
Expand Down

0 comments on commit 93d3460

Please sign in to comment.