regulator: tps65217: Fix NULL pointer dereference on probe
authorAnton Vasilyev <vasilyev@ispras.ru>
Fri, 27 Jul 2018 13:59:29 +0000 (16:59 +0300)
committerMark Brown <broonie@kernel.org>
Mon, 30 Jul 2018 08:41:04 +0000 (09:41 +0100)
There is no check that tps->strobes is allocated successfully in
tps65217_regulator_probe().
The patch adds corresponding check.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Anton Vasilyev <vasilyev@ispras.ru>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/tps65217-regulator.c

index fc12bad..d84fab6 100644 (file)
@@ -232,6 +232,8 @@ static int tps65217_regulator_probe(struct platform_device *pdev)
        tps->strobes = devm_kcalloc(&pdev->dev,
                                    TPS65217_NUM_REGULATOR, sizeof(u8),
                                    GFP_KERNEL);
+       if (!tps->strobes)
+               return -ENOMEM;
 
        platform_set_drvdata(pdev, tps);