Thread (11 messages) 11 messages, 2 authors, 2009-08-19

Re: Restoring joydev BTNMAP ioctl compatibility

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: 2009-08-11 11:51:25

On Tue, Aug 11, 2009 at 08:20:32AM +0200, Stephen Kitt wrote:
Hi Dmitry,

On Mon, 10 Aug 2009 13:27:26 -0700, Dmitry Torokhov
[off-list ref] wrote:
quoted
Actually I think we need to return "len" here to let userspace know how
much data we produced. Also, could you please give the same treatment to
JSIOCGAXMAP and JSIOCSAXMAP and I will apply it.
Here goes! I'm not too familiar with kernel memory handling, I'll send the
fixes for the FIXMEs later on as a separate patch once I've figured things
out; I'm thinking along these lines:
* vmalloc() a buffer
* return -ENOMEM if no memory is available
* copy_from_user the data into the temporary buffer
* validate the data
* on error vfree() the buffer and return -EINVAL
* copy the data from the temporary buffer to the destination array
* vfree() the buffer
Yep, exactly, except that don't bother with vmalloc, kmalloc will do
nicely since the amout of memory needed is relatively small.

-- 
Dmitry
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help