From: Daniele Nicolodi <daniele@domain.hid>
To: xenomai@xenomai.org
Subject: [Xenomai-core] Analogy a4l_ioctl_bufinfo() bug?
Date: Thu, 11 Mar 2010 17:26:01 +0100 [thread overview]
Message-ID: <4B991999.1070406@domain.hid> (raw)
Hello. As reported in the xenomai-help mailing list I'm investigating
why a4l_mmap() is not supported for the ni pcimio driver. Hacking on the
driver I discovered that, apparently, the only problem in supporting
mmap of the device buffer is in the a4l_ioctl_bufinfo() function.
In my interpretation, this function does more than what it promises.
>From the documentation it looks like it just has to return the current
buffer size. However, if my understanding is correct, it also copies
data to/from the hardware FIFO to the device buffer. It is unclear to me
why this is necessary.
In doing so it uses the __munge() function, around line 630 in buffer.h.
This function in turns uses the driver specific munge function. In the
case of the ni pcimio driver this function is ni_ai_munge16() in
mio_common.c. This function expects to be called when a valid command
has been sent to the subdevice, because it unconditionally deferences
cmd->nb_chan, around line 1385.
However, when the a4l_ioctl_bufinfo() function is called, there is no
check that a valid command has been sent to the device, and generally it
hasn't. This causes a kernel OOPS for trying to deference a NULL pointer.
My hacky solution has been to introduce a check, with an early return,
for a NULL cmd. I'm sure this is not the right solution.
However, to solve the problem properly, I need to understand why
a4l_ioctl_bufinfo() has to mess with the buffer data, when it is only
interested into the buffer dimensions.
Thanks. Cheers,
--
Daniele
next reply other threads:[~2010-03-11 16:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-11 16:26 Daniele Nicolodi [this message]
2010-03-17 14:36 ` [Xenomai-core] Analogy a4l_ioctl_bufinfo() bug? Daniele Nicolodi
2010-03-19 0:08 ` Alexis Berlemont
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=4B991999.1070406@domain.hid \
--to=daniele@domain.hid \
--cc=xenomai@xenomai.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 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.