Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

regulator: s5m8767: Prevent possible NULL pointer dereference

s5m8767_pmic_dt_parse_pdata dereferenes pdata, thus check pdata earlier to
avoid NULL pointer dereference.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

authored by

Axel Lin and committed by
Mark Brown
e81d7bc8 cbb0ed49

+5 -5
+5 -5
drivers/regulator/s5m8767.c
··· 659 659 struct s5m8767_info *s5m8767; 660 660 int i, ret, size, buck_init; 661 661 662 + if (!pdata) { 663 + dev_err(pdev->dev.parent, "Platform data not supplied\n"); 664 + return -ENODEV; 665 + } 666 + 662 667 if (iodev->dev->of_node) { 663 668 ret = s5m8767_pmic_dt_parse_pdata(pdev, pdata); 664 669 if (ret) 665 670 return ret; 666 - } 667 - 668 - if (!pdata) { 669 - dev_err(pdev->dev.parent, "Platform data not supplied\n"); 670 - return -ENODEV; 671 671 } 672 672 673 673 if (pdata->buck2_gpiodvs) {