From: Jarod Wilson <jarod@redhat.com>
To: Andy Walls <awalls@md.metrocast.net>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH 5/6] lirc_zilog: error out if buffer read bytes != chunk size
Date: Thu, 17 Mar 2011 11:42:04 -0400 [thread overview]
Message-ID: <20110317154204.GB5941@redhat.com> (raw)
In-Reply-To: <210cb1d1-4426-4b73-92aa-ec4337d9642c@email.android.com>
On Thu, Mar 17, 2011 at 11:29:08AM -0400, Andy Walls wrote:
> Jarod Wilson <jarod@redhat.com> wrote:
>
> >On Wed, Mar 16, 2011 at 08:07:22PM -0400, Andy Walls wrote:
> >> On Wed, 2011-03-16 at 16:24 -0400, Jarod Wilson wrote:
> >> > Signed-off-by: Jarod Wilson <jarod@redhat.com>
> >> > ---
> >> > drivers/staging/lirc/lirc_zilog.c | 4 ++++
> >> > 1 files changed, 4 insertions(+), 0 deletions(-)
> >> >
> >> > diff --git a/drivers/staging/lirc/lirc_zilog.c
> >b/drivers/staging/lirc/lirc_zilog.c
> >> > index 407d4b4..5ada643 100644
> >> > --- a/drivers/staging/lirc/lirc_zilog.c
> >> > +++ b/drivers/staging/lirc/lirc_zilog.c
> >> > @@ -950,6 +950,10 @@ static ssize_t read(struct file *filep, char
> >*outbuf, size_t n, loff_t *ppos)
> >> > ret = copy_to_user((void *)outbuf+written, buf,
> >> > rbuf->chunk_size);
> >> > written += rbuf->chunk_size;
> >> > + } else {
> >> > + zilog_error("Buffer read failed!\n");
> >> > + ret = -EIO;
> >> > + break;
> >>
> >> No need to break, just let the non-0 ret value drop you out of the
> >while
> >> loop.
> >
> >Ah, indeed. I think I mindlessly copied what the tests just a few lines
> >above were doing without looking at the actual reason for them. I'll
> >remove that break from the patch here locally.
> >
> >--
> >Jarod Wilson
> >jarod@redhat.com
>
> You might also want to take a look at that test to ensure it doesn't break blocking read() behavior. (man 2 read). I'm swamped ATM and didn't look too hard.
>
> It seems odd that the lirc buffer object can have data ready (the first branch of the big if() in the while() loop), and yet the read of that lirc buffer object fails.
Generally, it shouldn't, but lirc_buffer_read uses kfifo underneath, and
in the pre-2.6.33 kfifo implementation, the retval from lirc_buffer_read
(as backported by way of media_build) is always 0, which is of course not
equal to chunk_size. So I think that in current kernels, this should never
trigger, and its partially just a note-to-self that this check will go
sideways when running on an older kernel, but not a bad check to have if
something really does go wrong.
--
Jarod Wilson
jarod@redhat.com
next prev parent reply other threads:[~2011-03-17 15:42 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-16 20:24 [PATCH 0/6] media: trivial IR fixes Jarod Wilson
2011-03-16 20:24 ` [PATCH 1/6] docs: fix typo in lirc_device_interface.xml Jarod Wilson
2011-03-16 20:24 ` [PATCH 2/6] imon: add more panel scancode mappings Jarod Wilson
2011-03-16 20:24 ` [PATCH 3/6] ir-kbd-i2c: pass device code w/key in hauppauge case Jarod Wilson
2011-03-16 20:24 ` [PATCH 4/6] lirc: silence some compile warnings Jarod Wilson
2011-03-16 20:24 ` [PATCH 5/6] lirc_zilog: error out if buffer read bytes != chunk size Jarod Wilson
2011-03-17 0:07 ` Andy Walls
2011-03-17 13:19 ` Jarod Wilson
2011-03-17 15:29 ` Andy Walls
2011-03-17 15:42 ` Jarod Wilson [this message]
2011-03-17 16:16 ` Andy Walls
2011-03-17 19:08 ` Jarod Wilson
2011-03-18 0:50 ` Andy Walls
2011-03-22 20:39 ` Jarod Wilson
2011-03-16 20:24 ` [PATCH 6/6] mceusb: topseed 0x0011 needs gen3 init for tx to work Jarod Wilson
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=20110317154204.GB5941@redhat.com \
--to=jarod@redhat.com \
--cc=awalls@md.metrocast.net \
--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