LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Yizhuo Zhai <yzhai003@ucr.edu>
To: unlisted-recipients:; (no To-header on input)
Cc: Yizhuo Zhai <yzhai003@ucr.edu>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Juan Antonio Aldea-Armenteros <juant.aldea@gmail.com>,
linux-media@vger.kernel.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: [PATCH v4] media: atomisp: fix the uninitialized use and rename "retvalue"
Date: Wed, 11 Aug 2021 22:54:17 -0700 [thread overview]
Message-ID: <20210812055421.44450-1-yzhai003@ucr.edu> (raw)
In-Reply-To: <20210723003607.64179-1-yzhai003@ucr.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@ucr.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.25.1
next prev parent reply other threads:[~2021-08-12 5:56 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-22 22:51 linux-next: Fixes tag needs some work in the v4l-dvb-next tree Stephen Rothwell
2021-07-23 0:36 ` [PATCH v4] media: atomisp: fix the uninitialized use and rename "retvalue" Yizhuo
2021-07-23 8:10 ` Dan Carpenter
2021-07-23 9:19 ` Yizhuo Zhai
2021-08-11 3:54 ` Yizhuo Zhai
2021-08-11 4:19 ` Yizhuo Zhai
2021-08-11 7:01 ` Greg Kroah-Hartman
2021-08-12 5:50 ` Yizhuo Zhai
2021-08-12 5:54 ` Yizhuo Zhai [this message]
2021-08-12 6:52 ` Sakari Ailus
2021-08-12 6:52 ` Greg Kroah-Hartman
2021-08-12 7:34 ` Yizhuo Zhai
2021-08-12 7:46 ` Greg Kroah-Hartman
2021-07-23 0:38 ` linux-next: Fixes tag needs some work in the v4l-dvb-next tree Yizhuo Zhai
2021-07-23 0:58 ` Stephen Rothwell
2021-07-23 2:19 ` Yizhuo Zhai
2021-07-23 7:04 ` Mauro Carvalho Chehab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210812055421.44450-1-yzhai003@ucr.edu \
--to=yzhai003@ucr.edu \
--cc=gregkh@linuxfoundation.org \
--cc=juant.aldea@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--subject='Re: [PATCH v4] media: atomisp: fix the uninitialized use and rename "retvalue"' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).