From: Anton Vasilyev Date: Fri, 27 Jul 2018 13:59:29 +0000 (+0300) Subject: regulator: tps65217: Fix NULL pointer dereference on probe X-Git-Tag: v4.18.9~47 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=9d8c6300d1585e7f97f2b0e371659e5a5c0bc510;p=users%2Fdwmw2%2Flinux.git regulator: tps65217: Fix NULL pointer dereference on probe [ 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 Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/regulator/tps65217-regulator.c b/drivers/regulator/tps65217-regulator.c index fc12badf38059..d84fab616abf4 100644 --- a/drivers/regulator/tps65217-regulator.c +++ b/drivers/regulator/tps65217-regulator.c @@ -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);