Commit 21bb55ac authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] drivers/ieee1394 annotation

Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f51b9905
...@@ -2518,7 +2518,7 @@ static int handle_dv1394_init(unsigned int fd, unsigned int cmd, unsigned long a ...@@ -2518,7 +2518,7 @@ static int handle_dv1394_init(unsigned int fd, unsigned int cmd, unsigned long a
if (file->f_op->ioctl != dv1394_ioctl) if (file->f_op->ioctl != dv1394_ioctl)
return -EFAULT; return -EFAULT;
if (copy_from_user(&dv32, (void *)arg, sizeof(dv32))) if (copy_from_user(&dv32, (void __user *)arg, sizeof(dv32)))
return -EFAULT; return -EFAULT;
dv.api_version = dv32.api_version; dv.api_version = dv32.api_version;
...@@ -2568,7 +2568,7 @@ static int handle_dv1394_get_status(unsigned int fd, unsigned int cmd, unsigned ...@@ -2568,7 +2568,7 @@ static int handle_dv1394_get_status(unsigned int fd, unsigned int cmd, unsigned
dv32.n_clear_frames = dv.n_clear_frames; dv32.n_clear_frames = dv.n_clear_frames;
dv32.dropped_frames = dv.dropped_frames; dv32.dropped_frames = dv.dropped_frames;
if (copy_to_user((struct dv1394_status32 *)arg, &dv32, sizeof(dv32))) if (copy_to_user((struct dv1394_status32 __user *)arg, &dv32, sizeof(dv32)))
ret = -EFAULT; ret = -EFAULT;
} }
......
...@@ -55,13 +55,8 @@ ...@@ -55,13 +55,8 @@
#include "raw1394.h" #include "raw1394.h"
#include "raw1394-private.h" #include "raw1394-private.h"
#if BITS_PER_LONG == 64 #define int2ptr(x) ((void __user *)(unsigned long)x)
#define int2ptr(x) ((void __user *)x)
#define ptr2int(x) ((u64)(unsigned long)(void __user *)x) #define ptr2int(x) ((u64)(unsigned long)(void __user *)x)
#else
#define int2ptr(x) ((void __user *)(u32)x)
#define ptr2int(x) ((u64)(unsigned long)(void __user *)x)
#endif
#ifdef CONFIG_IEEE1394_VERBOSEDEBUG #ifdef CONFIG_IEEE1394_VERBOSEDEBUG
#define RAW1394_DEBUG #define RAW1394_DEBUG
...@@ -1629,7 +1624,7 @@ static int arm_register(struct file_info *fi, struct pending_request *req) ...@@ -1629,7 +1624,7 @@ static int arm_register(struct file_info *fi, struct pending_request *req)
if (another_host) { if (another_host) {
DBGMSG("another hosts entry is valid -> SUCCESS"); DBGMSG("another hosts entry is valid -> SUCCESS");
if (copy_to_user(int2ptr(req->req.recvb), if (copy_to_user(int2ptr(req->req.recvb),
int2ptr(&addr->start),sizeof(u64))) { &addr->start,sizeof(u64))) {
printk(KERN_ERR "raw1394: arm_register failed " printk(KERN_ERR "raw1394: arm_register failed "
" address-range-entry is invalid -> EFAULT !!!\n"); " address-range-entry is invalid -> EFAULT !!!\n");
vfree(addr->addr_space_buffer); vfree(addr->addr_space_buffer);
......
...@@ -1003,11 +1003,9 @@ static int video1394_ioctl(struct inode *inode, struct file *file, ...@@ -1003,11 +1003,9 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
case VIDEO1394_IOC_TALK_QUEUE_BUFFER: case VIDEO1394_IOC_TALK_QUEUE_BUFFER:
{ {
struct video1394_wait v; struct video1394_wait v;
struct video1394_queue_variable qv; unsigned int *psizes = NULL;
struct dma_iso_ctx *d; struct dma_iso_ctx *d;
qv.packet_sizes = NULL;
if (copy_from_user(&v, argp, sizeof(v))) if (copy_from_user(&v, argp, sizeof(v)))
return -EFAULT; return -EFAULT;
...@@ -1021,22 +1019,21 @@ static int video1394_ioctl(struct inode *inode, struct file *file, ...@@ -1021,22 +1019,21 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
} }
if (d->flags & VIDEO1394_VARIABLE_PACKET_SIZE) { if (d->flags & VIDEO1394_VARIABLE_PACKET_SIZE) {
unsigned int *psizes;
int buf_size = d->nb_cmd * sizeof(unsigned int); int buf_size = d->nb_cmd * sizeof(unsigned int);
struct video1394_queue_variable __user *p = argp;
unsigned int __user *qv;
if (copy_from_user(&qv, argp, sizeof(qv))) if (get_user(qv, &p->packet_sizes))
return -EFAULT; return -EFAULT;
psizes = kmalloc(buf_size, GFP_KERNEL); psizes = kmalloc(buf_size, GFP_KERNEL);
if (!psizes) if (!psizes)
return -ENOMEM; return -ENOMEM;
if (copy_from_user(psizes, qv.packet_sizes, buf_size)) { if (copy_from_user(psizes, qv, buf_size)) {
kfree(psizes); kfree(psizes);
return -EFAULT; return -EFAULT;
} }
qv.packet_sizes = psizes;
} }
spin_lock_irqsave(&d->lock,flags); spin_lock_irqsave(&d->lock,flags);
...@@ -1045,14 +1042,14 @@ static int video1394_ioctl(struct inode *inode, struct file *file, ...@@ -1045,14 +1042,14 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
PRINT(KERN_ERR, ohci->host->id, PRINT(KERN_ERR, ohci->host->id,
"Buffer %d is already used",v.buffer); "Buffer %d is already used",v.buffer);
spin_unlock_irqrestore(&d->lock,flags); spin_unlock_irqrestore(&d->lock,flags);
if (qv.packet_sizes) if (psizes)
kfree(qv.packet_sizes); kfree(psizes);
return -EFAULT; return -EFAULT;
} }
if (d->flags & VIDEO1394_VARIABLE_PACKET_SIZE) { if (d->flags & VIDEO1394_VARIABLE_PACKET_SIZE) {
initialize_dma_it_prg_var_packet_queue( initialize_dma_it_prg_var_packet_queue(
d, v.buffer, qv.packet_sizes, d, v.buffer, psizes,
ohci); ohci);
} }
...@@ -1101,8 +1098,8 @@ static int video1394_ioctl(struct inode *inode, struct file *file, ...@@ -1101,8 +1098,8 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
} }
} }
if (qv.packet_sizes) if (psizes)
kfree(qv.packet_sizes); kfree(psizes);
return 0; return 0;
...@@ -1339,6 +1336,7 @@ struct video1394_wait32 { ...@@ -1339,6 +1336,7 @@ struct video1394_wait32 {
static int video1394_wr_wait32(unsigned int fd, unsigned int cmd, unsigned long arg, static int video1394_wr_wait32(unsigned int fd, unsigned int cmd, unsigned long arg,
struct file *file) struct file *file)
{ {
struct video1394_wait32 __user *argp = (void __user *)arg;
struct video1394_wait32 wait32; struct video1394_wait32 wait32;
struct video1394_wait wait; struct video1394_wait wait;
mm_segment_t old_fs; mm_segment_t old_fs;
...@@ -1347,7 +1345,7 @@ static int video1394_wr_wait32(unsigned int fd, unsigned int cmd, unsigned long ...@@ -1347,7 +1345,7 @@ static int video1394_wr_wait32(unsigned int fd, unsigned int cmd, unsigned long
if (file->f_op->ioctl != video1394_ioctl) if (file->f_op->ioctl != video1394_ioctl)
return -EFAULT; return -EFAULT;
if (copy_from_user(&wait32, (void *)arg, sizeof(wait32))) if (copy_from_user(&wait32, argp, sizeof(wait32)))
return -EFAULT; return -EFAULT;
wait.channel = wait32.channel; wait.channel = wait32.channel;
...@@ -1373,7 +1371,7 @@ static int video1394_wr_wait32(unsigned int fd, unsigned int cmd, unsigned long ...@@ -1373,7 +1371,7 @@ static int video1394_wr_wait32(unsigned int fd, unsigned int cmd, unsigned long
wait32.filltime.tv_sec = (int)wait.filltime.tv_sec; wait32.filltime.tv_sec = (int)wait.filltime.tv_sec;
wait32.filltime.tv_usec = (int)wait.filltime.tv_usec; wait32.filltime.tv_usec = (int)wait.filltime.tv_usec;
if (copy_to_user((struct video1394_wait32 *)arg, &wait32, sizeof(wait32))) if (copy_to_user(argp, &wait32, sizeof(wait32)))
ret = -EFAULT; ret = -EFAULT;
} }
...@@ -1391,7 +1389,7 @@ static int video1394_w_wait32(unsigned int fd, unsigned int cmd, unsigned long a ...@@ -1391,7 +1389,7 @@ static int video1394_w_wait32(unsigned int fd, unsigned int cmd, unsigned long a
if (file->f_op->ioctl != video1394_ioctl) if (file->f_op->ioctl != video1394_ioctl)
return -EFAULT; return -EFAULT;
if (copy_from_user(&wait32, (void *)arg, sizeof(wait32))) if (copy_from_user(&wait32, (void __user *)arg, sizeof(wait32)))
return -EFAULT; return -EFAULT;
wait.channel = wait32.channel; wait.channel = wait32.channel;
......
...@@ -53,7 +53,7 @@ struct video1394_mmap { ...@@ -53,7 +53,7 @@ struct video1394_mmap {
struct video1394_queue_variable { struct video1394_queue_variable {
unsigned int channel; unsigned int channel;
unsigned int buffer; unsigned int buffer;
unsigned int* packet_sizes; /* Buffer of size: unsigned int __user * packet_sizes; /* Buffer of size:
buf_size / packet_size */ buf_size / packet_size */
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment