Skip to contentSkip to conversation

media: st-mipid02: add a check for devm_gpiod_get_optional

PATCH New Chuhong Yuan 1 participant 1 message Oct 18, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 media: st-mipid02: add a check for devm_gpiod_get_optional

mipid02_probe misses a check for devm_gpiod_get_optional and may miss the failure.
Add a check to fix the problem.

---
Changes in v2:
- Add an error message.

 drivers/media/i2c/st-mipid02.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/media/i2c/st-mipid02.c +5 -0
index 81285b8d5cfb..003ba22334cd 100644
@@ -971,6 +971,11 @@ static int mipid02_probe(struct i2c_client *client)
 	bridge->reset_gpio = devm_gpiod_get_optional(dev, "reset",
 						     GPIOD_OUT_HIGH);
 
+	if (IS_ERR(bridge->reset_gpio)) {
+		dev_err(dev, "failed to get reset GPIO\n");
+		return PTR_ERR(bridge->reset_gpio);
+	}
+
 	ret = mipid02_get_regulators(bridge);
 	if (ret) {
 		dev_err(dev, "failed to get regulators %d", ret);
Signature · 1 line
2.20.1