public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Walls <awalls@md.metrocast.net>
To: Dan Carpenter <error27@gmail.com>
Cc: Srinivasa.Deevi@conexant.com, linux-media@vger.kernel.org
Subject: Re: smatch report: cx231xx: incorrect check in cx231xx_write_i2c_data()
Date: Thu, 23 Dec 2010 13:34:52 -0500	[thread overview]
Message-ID: <1293129292.24752.9.camel@morgan.silverblock.net> (raw)
In-Reply-To: <20101223164347.GA16612@bicker>

On Thu, 2010-12-23 at 19:43 +0300, Dan Carpenter wrote:
> Hi,
> 
> I was doing an audit and I came across this.
> 
> drivers/media/video/cx231xx/cx231xx-core.c +1644 cx231xx_write_i2c_data(14)
> 	warn: 'saddr_len' is non-zero. Did you mean 'saddr'
> 
>   1642          if (saddr_len == 0)
>   1643                  saddr = 0;
>   1644          else if (saddr_len == 0)
>   1645                  saddr &= 0xff;
> 
> We check "saddr_len == 0" twice which doesn't make sense.  I'm not sure
> what the correct fix is though.

Given that "saddr" probably means "sub-address", that "saddr_len"
probably means "sub-address length", that saddr is only a 16 bit value,
and this switch in cx231xx_send_usb_command():

        /* set index value */
        switch (saddr_len) {
        case 0:
                ven_req.wIndex = 0;     /* need check */
                break;
        case 1:
                ven_req.wIndex = (req_data->saddr_dat & 0xff);
                break;
        case 2:
                ven_req.wIndex = req_data->saddr_dat;
                break;
        }

and noting that "req_data->saddr_dat" holds what was "saddr";
the if statement, and the many others like it, should probably be:

	if (saddr_len == 0)
		saddr = 0;
	else if (saddr_len == 1)       <----- == 1
		saddr &= 0xff;


Regards,
Andy

>   It's been this way since the driver was
> merged.
> 
> regards,
> dan carpenter




  reply	other threads:[~2010-12-23 18:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-23 16:43 smatch report: cx231xx: incorrect check in cx231xx_write_i2c_data() Dan Carpenter
2010-12-23 18:34 ` Andy Walls [this message]
2010-12-23 18:55   ` Dan Carpenter
     [not found]   ` <34B38BE41EDBA046A4AFBB591FA311320249B057C6@NBMBX01.bbnet.ad>
2010-12-23 19:38     ` [patch] [media] cx231xxx: fix typo in saddr_len check Dan Carpenter
2010-12-23 19:40       ` Sri Deevi

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=1293129292.24752.9.camel@morgan.silverblock.net \
    --to=awalls@md.metrocast.net \
    --cc=Srinivasa.Deevi@conexant.com \
    --cc=error27@gmail.com \
    --cc=linux-media@vger.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