regulator: tps65218: Add NULL test for devm_kzalloc call
authorAxel Lin <axel.lin@ingics.com>
Mon, 13 Nov 2017 12:52:32 +0000 (20:52 +0800)
committerMark Brown <broonie@kernel.org>
Thu, 16 Nov 2017 11:59:09 +0000 (11:59 +0000)
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Reviewed-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/tps65218-regulator.c

index b6f7052..1827185 100644 (file)
@@ -326,6 +326,8 @@ static int tps65218_regulator_probe(struct platform_device *pdev)
        /* Allocate memory for strobes */
        tps->strobes = devm_kzalloc(&pdev->dev, sizeof(u8) *
                                    TPS65218_NUM_REGULATOR, GFP_KERNEL);
+       if (!tps->strobes)
+               return -ENOMEM;
 
        for (i = 0; i < ARRAY_SIZE(regulators); i++) {
                rdev = devm_regulator_register(&pdev->dev, &regulators[i],