ASoC: ux500: Strengthen error checking after memory allocation

Currently there is no out-of-memory error checking after attempting
to allocate memory for the ux500_msp or ux500_msp_i2s_drvdata data
structures. Instead we go about populating them regardless. This
patch applies the necessary error checking to prevent a panic.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
Lee Jones 2012-07-26 11:28:37 +01:00 committed by Mark Brown
parent fbfe69836c
commit 0dcd47426a
2 changed files with 5 additions and 0 deletions

View File

@ -760,6 +760,9 @@ static int __devinit ux500_msp_drv_probe(struct platform_device *pdev)
drvdata = devm_kzalloc(&pdev->dev, drvdata = devm_kzalloc(&pdev->dev,
sizeof(struct ux500_msp_i2s_drvdata), sizeof(struct ux500_msp_i2s_drvdata),
GFP_KERNEL); GFP_KERNEL);
if (!drvdata)
return -ENOMEM;
drvdata->fmt = 0; drvdata->fmt = 0;
drvdata->slots = 1; drvdata->slots = 1;
drvdata->tx_mask = 0x01; drvdata->tx_mask = 0x01;

View File

@ -673,6 +673,8 @@ int ux500_msp_i2s_init_msp(struct platform_device *pdev,
*msp_p = devm_kzalloc(&pdev->dev, sizeof(struct ux500_msp), GFP_KERNEL); *msp_p = devm_kzalloc(&pdev->dev, sizeof(struct ux500_msp), GFP_KERNEL);
msp = *msp_p; msp = *msp_p;
if (!msp)
return -ENOMEM;
msp->id = platform_data->id; msp->id = platform_data->id;
msp->dev = &pdev->dev; msp->dev = &pdev->dev;