Skip to content

Commit e3b53b8

Browse files
GustavoARSilvabroonie
authored andcommitted
regulator: qcom_smd: add NULL check on of_match_device() return value
Check return value from call to of_match_device() in order to prevent a NULL pointer dereference. In case of NULL print error message and return. Signed-off-by: Gustavo A. R. Silva <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 2f2472b commit e3b53b8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/regulator/qcom_smd-regulator.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,11 @@ static int rpm_reg_probe(struct platform_device *pdev)
570570
}
571571

572572
match = of_match_device(rpm_of_match, &pdev->dev);
573+
if (!match) {
574+
dev_err(&pdev->dev, "failed to match device\n");
575+
return -ENODEV;
576+
}
577+
573578
for (reg = match->data; reg->name; reg++) {
574579
vreg = devm_kzalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL);
575580
if (!vreg)

0 commit comments

Comments
 (0)