Commit c59d7ae2 authored by Joe Burks's avatar Joe Burks Committed by Linus Torvalds

[PATCH] USB: vicam.c patch

I noticed a version of vicam.c a few revisions ago had all the /proc fs
writing removed because I was incorrectly using potentially tainted user
space pointers.  Here's a patch which I think fixes the pointer issue and
restores the /proc fs interface to vicam.  If this fix is still
problematic, please let me know and I'll fix whatever comes up.
parent 8dd533ce
...@@ -1101,6 +1101,52 @@ static int vicam_read_proc_gain(char *page, char **start, off_t off, ...@@ -1101,6 +1101,52 @@ static int vicam_read_proc_gain(char *page, char **start, off_t off,
((struct vicam_camera *)data)->gain); ((struct vicam_camera *)data)->gain);
} }
static int
vicam_write_proc_shutter(struct file *file, const char *buffer,
unsigned long count, void *data)
{
u16 stmp;
char kbuf[8];
struct vicam_camera *cam = (struct vicam_camera *) data;
if (count > 6)
return -EINVAL;
if (copy_from_user(kbuf, buffer, count))
return -EFAULT;
stmp = (u16) simple_strtoul(kbuf, NULL, 10);
if (stmp < 4 || stmp > 32000)
return -EINVAL;
cam->shutter_speed = stmp;
return count;
}
static int
vicam_write_proc_gain(struct file *file, const char *buffer,
unsigned long count, void *data)
{
u16 gtmp;
char kbuf[8];
struct vicam_camera *cam = (struct vicam_camera *) data;
if (count > 4)
return -EINVAL;
if (copy_from_user(kbuf, buffer, count))
return -EFAULT;
gtmp = (u16) simple_strtoul(kbuf, NULL, 10);
if (gtmp > 255)
return -EINVAL;
cam->gain = gtmp;
return count;
}
static void static void
vicam_create_proc_root(void) vicam_create_proc_root(void)
{ {
...@@ -1142,18 +1188,21 @@ vicam_create_proc_entry(struct vicam_camera *cam) ...@@ -1142,18 +1188,21 @@ vicam_create_proc_entry(struct vicam_camera *cam)
if ( !cam->proc_dir ) if ( !cam->proc_dir )
return; // FIXME: We should probably return an error here return; // FIXME: We should probably return an error here
ent = ent = create_proc_entry("shutter", S_IFREG | S_IRUGO | S_IWUSR,
create_proc_entry("shutter", S_IFREG | S_IRUGO, cam->proc_dir); cam->proc_dir);
if (ent) { if (ent) {
ent->data = cam; ent->data = cam;
ent->read_proc = vicam_read_proc_shutter; ent->read_proc = vicam_read_proc_shutter;
ent->write_proc = vicam_write_proc_shutter;
ent->size = 64; ent->size = 64;
} }
ent = create_proc_entry("gain", S_IFREG | S_IRUGO , cam->proc_dir); ent = create_proc_entry("gain", S_IFREG | S_IRUGO | S_IWUSR,
if ( ent ) { cam->proc_dir);
if (ent) {
ent->data = cam; ent->data = cam;
ent->read_proc = vicam_read_proc_gain; ent->read_proc = vicam_read_proc_gain;
ent->write_proc = vicam_write_proc_gain;
ent->size = 64; ent->size = 64;
} }
} }
......
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