Message ID | 20230816200410.62131-4-yann@sionneau.net |
---|---|
State | New |
Headers | show |
Series | i2c: devm_pinctrl_get() usage fixes | expand |
diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c index 9849f4502570..aa9ae0755674 100644 --- a/drivers/i2c/busses/i2c-cadence.c +++ b/drivers/i2c/busses/i2c-cadence.c @@ -1299,6 +1299,7 @@ static int cdns_i2c_probe(struct platform_device *pdev) if (IS_ERR(id->rinfo.pinctrl)) { int err = PTR_ERR(id->rinfo.pinctrl); + id->rinfo.pinctrl = NULL; dev_info(&pdev->dev, "can't get pinctrl, bus recovery not supported\n"); if (err != -ENODEV) return err;
The core i2c code generally checks if pinctrl has been properly initialized by just doing 'if (p) some_pinctrl_function(p)'. In case devm_pinctrl_get() fails, pinctrl variable contains an error instead of a valid pointer. To prevent core i2c code to crash, reset back pinctrl pointer to NULL when this happens. Signed-off-by: Yann Sionneau <yann@sionneau.net> --- drivers/i2c/busses/i2c-cadence.c | 1 + 1 file changed, 1 insertion(+)