[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABvMjLRj-ofVoNpOvT+DPOdW-=L52KbsRYeaKv=MTYfSJPZNBA@mail.gmail.com>
Date: Tue, 10 Aug 2021 21:19:20 -0700
From: Yizhuo Zhai <yzhai003@....edu>
To: unlisted-recipients:; (no To-header on input)
Cc: Mauro Carvalho Chehab <mchehab@...nel.org>,
Sakari Ailus <sakari.ailus@...ux.intel.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Juan Antonio Aldea-Armenteros <juant.aldea@...il.com>,
linux-media@...r.kernel.org, linux-staging@...ts.linux.dev,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v4] media: atomisp: fix the uninitialized use and rename "retvalue"
Hi All:
For your information, I update my signed-off zone using my full name
"Yizhuo Zhai"
On Tue, Aug 10, 2021 at 8:54 PM Yizhuo Zhai <yzhai003@....edu> wrote:
>
> From: Yizhuo <yzhai003@....edu>
>
> 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.
>
> Fixes: ad85094b293e ("Revert "media: staging: atomisp: Remove driver"")
> Signed-off-by: Yizhuo Zhai<yzhai003@....edu>
> ---
> drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c b/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c
> index f5de81132177..77293579a134 100644
> --- a/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c
> +++ b/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c
> @@ -1533,16 +1533,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;
> --
> 2.17.1
>
--
Kind Regards,
Yizhuo Zhai
Computer Science, Graduate Student
University of California, Riverside
Powered by blists - more mailing lists