Skip to content

Commit

Permalink
media: atomisp: fix the uninitialized use and rename "retvalue"
Browse files Browse the repository at this point in the history
[ Upstream commit c275e5d ]

Inside function mt9m114_detect(), variable "retvalue" could
be uninitialized if mt9m114_read_reg() returns error, however, it
is used in the later if statement, which is potentially unsafe.

The local variable "retvalue" is renamed to "model" to avoid
confusion.

Link: https://lore.kernel.org/linux-media/20210625053858.3862-1-yzhai003@ucr.edu
Fixes: ad85094 (media / atomisp: fix the uninitialized use of model ID)
Signed-off-by: Yizhuo <yzhai003@ucr.edu>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Yizhuo authored and gregkh committed Sep 15, 2021
1 parent 01705a9 commit 41067ab
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c
Expand Up @@ -1545,16 +1545,19 @@ static struct v4l2_ctrl_config mt9m114_controls[] = {
static int mt9m114_detect(struct mt9m114_device *dev, struct i2c_client *client)
{
struct i2c_adapter *adapter = client->adapter;
u32 retvalue;
u32 model;
int ret;

if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
dev_err(&client->dev, "%s: i2c error", __func__);
return -ENODEV;
}
mt9m114_read_reg(client, MISENSOR_16BIT, (u32)MT9M114_PID, &retvalue);
dev->real_model_id = retvalue;
ret = mt9m114_read_reg(client, MISENSOR_16BIT, MT9M114_PID, &model);
if (ret)
return ret;
dev->real_model_id = model;

if (retvalue != MT9M114_MOD_ID) {
if (model != MT9M114_MOD_ID) {
dev_err(&client->dev, "%s: failed: client->addr = %x\n",
__func__, client->addr);
return -ENODEV;
Expand Down

0 comments on commit 41067ab

Please sign in to comment.