]> git.hungrycats.org Git - linux/commitdiff
regulator: tps65217: Fix NULL pointer dereference on probe
authorAnton Vasilyev <vasilyev@ispras.ru>
Fri, 27 Jul 2018 13:59:29 +0000 (16:59 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Sep 2018 20:41:33 +0000 (22:41 +0200)
[ Upstream commit 4f919ca2bf6da826ba1a4316e1b8e9c94e5dbeb2 ]

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>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/regulator/tps65217-regulator.c

index fc12badf38059f96b4bea38a6ffaed8bd9a71dbc..d84fab616abf45cde4e04887500ed57aa4fc5ea9 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);