]> rtime.felk.cvut.cz Git - can-eth-gw-linux.git/commitdiff
ASoC: ux500: Strengthen error checking after memory allocation
authorLee Jones <lee.jones@linaro.org>
Thu, 26 Jul 2012 10:28:37 +0000 (11:28 +0100)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Fri, 3 Aug 2012 22:03:55 +0000 (23:03 +0100)
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>
sound/soc/ux500/ux500_msp_dai.c
sound/soc/ux500/ux500_msp_i2s.c

index 057e28ef770ecbd9582078acb9db8cd7a83f8e4b..772cb19d2fb328ddd29e6dc4c8fddf73bd02c291 100644 (file)
@@ -760,6 +760,9 @@ static int __devinit ux500_msp_drv_probe(struct platform_device *pdev)
        drvdata = devm_kzalloc(&pdev->dev,
                                sizeof(struct ux500_msp_i2s_drvdata),
                                GFP_KERNEL);
+       if (!drvdata)
+               return -ENOMEM;
+
        drvdata->fmt = 0;
        drvdata->slots = 1;
        drvdata->tx_mask = 0x01;
index 5c472f335a64d6e5c11a5ee82e755153312ee40b..36be11e47ad60b7eb0f8fe909e24d45393baee13 100644 (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 = *msp_p;
+       if (!msp)
+               return -ENOMEM;
 
        msp->id = platform_data->id;
        msp->dev = &pdev->dev;