linux-staging.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Yizhuo Zhai <yzhai003@ucr.edu>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
	akari.ailus@linux.intel.com,
	 Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	juant.aldea@gmail.com,  linux-media@vger.kernel.org,
	linux-staging@lists.linux.dev,  linux-kernel@vger.kernel.org
Subject: [PATCH] media: atomisp: fix the uninitialized use
Date: Tue, 15 Jun 2021 11:45:38 -0700	[thread overview]
Message-ID: <CABvMjLRkmsrxXxHkX7PrkoRK5m=7_b3wpvyZK88V19b05CFx2w@mail.gmail.com> (raw)

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.

Signed-off-by: Yizhuo <yzhai003@ucr.edu>
---
 drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c
b/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c
index f5de81132177..8ddddb18ffbb 100644
--- a/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c
+++ b/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c
@@ -1534,12 +1534,15 @@ static int mt9m114_detect(struct
mt9m114_device *dev, struct i2c_client *client)
 {
        struct i2c_adapter *adapter = client->adapter;
        u32 retvalue;
+       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);
+       ret = mt9m114_read_reg(client, MISENSOR_16BIT,
(u32)MT9M114_PID, &retvalue);
+       if (ret)
+               return ret;
        dev->real_model_id = retvalue;

        if (retvalue != MT9M114_MOD_ID) {
-- 
2.17.1

             reply	other threads:[~2021-06-15 18:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-15 18:45 Yizhuo Zhai [this message]
2021-06-18 10:37 ` [PATCH] media: atomisp: fix the uninitialized use Hans Verkuil

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='CABvMjLRkmsrxXxHkX7PrkoRK5m=7_b3wpvyZK88V19b05CFx2w@mail.gmail.com' \
    --to=yzhai003@ucr.edu \
    --cc=akari.ailus@linux.intel.com \
    --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 \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).