mirror of
https://github.com/torvalds/linux.git
synced 2026-09-26 10:02:02 +02:00
media: i2c: mt9t112: fix incorrect PTR_ERR() call on non-error pointer
In mt9t112_probe(), the clock error check after devm_v4l2_sensor_clk_get() calls PTR_ERR(priv->clk) unconditionally, before testing IS_ERR(). On a successful lookup, priv->clk is a valid pointer and calling PTR_ERR() on it is incorrect API usage. While the comparison against -ENOENT happens to be harmless in practice (valid kernel pointers never fall in the error range), this is still a violation of the IS_ERR()/PTR_ERR() contract that can mislead readers. Restructure the check to guard PTR_ERR() inside IS_ERR(), using the simpler != -ENOENT form to avoid an unnecessary else clause. Signed-off-by: Uday Khare <udaykhare77@gmail.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
This commit is contained in:
parent
d836f57e8a
commit
642f8aa04c
|
|
@ -1079,11 +1079,12 @@ static int mt9t112_probe(struct i2c_client *client)
|
|||
v4l2_i2c_subdev_init(&priv->subdev, client, &mt9t112_subdev_ops);
|
||||
|
||||
priv->clk = devm_v4l2_sensor_clk_get(&client->dev, "extclk");
|
||||
if (PTR_ERR(priv->clk) == -ENOENT)
|
||||
if (IS_ERR(priv->clk)) {
|
||||
if (PTR_ERR(priv->clk) != -ENOENT)
|
||||
return dev_err_probe(&client->dev, PTR_ERR(priv->clk),
|
||||
"Unable to get clock \"extclk\"\n");
|
||||
priv->clk = NULL;
|
||||
else if (IS_ERR(priv->clk))
|
||||
return dev_err_probe(&client->dev, PTR_ERR(priv->clk),
|
||||
"Unable to get clock \"extclk\"\n");
|
||||
}
|
||||
|
||||
priv->standby_gpio = devm_gpiod_get_optional(&client->dev, "standby",
|
||||
GPIOD_OUT_HIGH);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user