public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@kernel.org>
To: Tuo Li <islituo@gmail.com>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	baijiaju1990@gmail.com, TOTE Robot <oslab@tsinghua.edu.cn>
Subject: Re: [PATCH] media: isl6421: fix possible uninitialized-variable access in isl6421_set_voltage()
Date: Fri, 19 Nov 2021 16:28:31 +0000	[thread overview]
Message-ID: <20211119162831.7f3b39a0@sal.lan> (raw)
In-Reply-To: <20210731073806.60142-1-islituo@gmail.com>

Em Sat, 31 Jul 2021 00:38:06 -0700
Tuo Li <islituo@gmail.com> escreveu:

> A memory block is allocated through kmalloc(), and its return value is
> assigned to the pointer isl6421. Then isl6421 is assigned to the
> varialbe fe->sec_priv. The function isl6421_set_voltage() is called with
> the argument fe. In this function, fe->sec_priv is assigned to isl6421.
> Thus the pointer isl6421 in the function isl6421_attach() and the function
> isl6421_set_voltage() point to the same memory. However, isl6421->is_off
> is not initialized but it is accessed at line 75:
>   if (isl6421->is_off && !is_off)
> 
> To fix this possible uninitialized-variable access, isl6421->is_off is
> initialized to false in the function isl6421_attach().
> 
> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
> Signed-off-by: Tuo Li <islituo@gmail.com>
> ---
>  drivers/media/dvb-frontends/isl6421.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/media/dvb-frontends/isl6421.c b/drivers/media/dvb-frontends/isl6421.c
> index 43b0dfc6f453..ea101f66ea88 100644
> --- a/drivers/media/dvb-frontends/isl6421.c
> +++ b/drivers/media/dvb-frontends/isl6421.c
> @@ -185,6 +185,7 @@ struct dvb_frontend *isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter
>  	isl6421->config = ISL6421_ISEL1;
>  	isl6421->i2c = i2c;
>  	isl6421->i2c_addr = i2c_addr;
> +	isl6421->is_off = false;
>  	fe->sec_priv = isl6421;

No need. The driver always initialize it:

        /* default configuration */
        isl6421->config = ISL6421_ISEL1;
        isl6421->i2c = i2c;
        isl6421->i2c_addr = i2c_addr;
        fe->sec_priv = isl6421;
 
        /* bits which should be forced to '1' */
        isl6421->override_or = override_set;
 
        /* bits which should be forced to '0' */
        isl6421->override_and = ~override_clear;
 
        /* detect if it is present or not */
        if (isl6421_set_voltage(fe, SEC_VOLTAGE_OFF)) {
                kfree(isl6421);
                fe->sec_priv = NULL;
                return NULL;
        }
 
        isl6421->is_off = true;
	^^^^^^^^^^^^^^^^^^^^^^^

(except if errors, in which case the struct is freed)

It sounds that your bot is misleading you to write an useless patch

;-)

Regards,
Mauro

      reply	other threads:[~2021-11-19 16:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-31  7:38 [PATCH] media: isl6421: fix possible uninitialized-variable access in isl6421_set_voltage() Tuo Li
2021-11-19 16:28 ` Mauro Carvalho Chehab [this message]

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=20211119162831.7f3b39a0@sal.lan \
    --to=mchehab@kernel.org \
    --cc=baijiaju1990@gmail.com \
    --cc=islituo@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=oslab@tsinghua.edu.cn \
    /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