Browse Source

regulator: tps65218: Add NULL test for devm_kzalloc call

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Reviewed-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Axel Lin 7 năm trước cách đây
mục cha
commit
5597bfb474
1 tập tin đã thay đổi với 2 bổ sung0 xóa
  1. 2 0
      drivers/regulator/tps65218-regulator.c

+ 2 - 0
drivers/regulator/tps65218-regulator.c

@@ -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],