From: Dan Carpenter <dan.carpenter@oracle.com>
To: Wei Yongjun <weiyj.lk@gmail.com>
Cc: devel@driverdev.osuosl.org, mchehab@redhat.com,
gregkh@linuxfoundation.org, yongjun_wei@trendmicro.com.cn,
hans.verkuil@cisco.com, linux-media@vger.kernel.org
Subject: Re: [PATCH -next] [media] go7007: fix invalid use of sizeof in go7007_usb_i2c_master_xfer()
Date: Tue, 26 Mar 2013 10:35:57 +0300 [thread overview]
Message-ID: <20130326073557.GI9138@mwanda> (raw)
In-Reply-To: <20130326070415.GH9138@mwanda>
On Tue, Mar 26, 2013 at 10:04:15AM +0300, Dan Carpenter wrote:
> On Tue, Mar 26, 2013 at 02:42:47PM +0800, Wei Yongjun wrote:
> > From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> >
> > sizeof() when applied to a pointer typed expression gives the
> > size of the pointer, not that of the pointed data.
> >
>
> This fix isn't right. "buf" is a char pointer. I don't know what
> this code is doing. Instead of sizeof(*buf) it should be something
> like "buflen", "msg[i].len", "msg[i].len + 1" or "msg[i].len + 3".
It should be "msg[i].len + 1", I think.
On the line before it writes buflen bytes to the hardware. Then
it clears the transfer buffer and reads "msg[i].len + 1" bytes from
the hardware. Then it saves the memory, except for the first byte,
in msg[i].buf.
So it should clear "msg[i].len + 1" bytes so that the old data isn't
confused with the data that we read from the hardware.
regards,
dan carpenter
next prev parent reply other threads:[~2013-03-26 7:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-26 6:42 [PATCH -next] [media] go7007: fix invalid use of sizeof in go7007_usb_i2c_master_xfer() Wei Yongjun
2013-03-26 7:04 ` Dan Carpenter
2013-03-26 7:35 ` Dan Carpenter [this message]
2013-03-26 8:18 ` Hans Verkuil
2013-03-26 8:30 ` Wei Yongjun
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=20130326073557.GI9138@mwanda \
--to=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=hans.verkuil@cisco.com \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@redhat.com \
--cc=weiyj.lk@gmail.com \
--cc=yongjun_wei@trendmicro.com.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.