diff options
author | Dean Anderson <dean@sensoray.com> | 2010-04-08 22:40:31 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-05-19 11:57:23 -0400 |
commit | c0a2ec956d6e61081b6f98b839b0e28979941687 (patch) | |
tree | 1df165fa55fd8f1880c9e77ba66e2fbf625dfeb6 /drivers/media/video/s2255drv.c | |
parent | ab85c6a33c7168cc42ce12ac3335c2f12d5a8d22 (diff) |
V4L/DVB: s2255drv: video_device_alloc call not checked fix
call to video_device_alloc was not being checked in probe function.
code simplified and uses video_device inside device structure.
Signed-off-by: Dean Anderson <dean@sensoray.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/s2255drv.c')
-rw-r--r-- | drivers/media/video/s2255drv.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c index 91f7e9538f6e..4c5d3672e2db 100644 --- a/drivers/media/video/s2255drv.c +++ b/drivers/media/video/s2255drv.c | |||
@@ -224,6 +224,7 @@ struct s2255_pipeinfo { | |||
224 | struct s2255_fmt; /*forward declaration */ | 224 | struct s2255_fmt; /*forward declaration */ |
225 | 225 | ||
226 | struct s2255_dev { | 226 | struct s2255_dev { |
227 | struct video_device vdev[MAX_CHANNELS]; | ||
227 | int frames; | 228 | int frames; |
228 | struct mutex lock; | 229 | struct mutex lock; |
229 | struct mutex open_lock; | 230 | struct mutex open_lock; |
@@ -233,7 +234,6 @@ struct s2255_dev { | |||
233 | u8 read_endpoint; | 234 | u8 read_endpoint; |
234 | 235 | ||
235 | struct s2255_dmaqueue vidq[MAX_CHANNELS]; | 236 | struct s2255_dmaqueue vidq[MAX_CHANNELS]; |
236 | struct video_device *vdev[MAX_CHANNELS]; | ||
237 | struct timer_list timer; | 237 | struct timer_list timer; |
238 | struct s2255_fw *fw_data; | 238 | struct s2255_fw *fw_data; |
239 | struct s2255_pipeinfo pipe; | 239 | struct s2255_pipeinfo pipe; |
@@ -719,10 +719,10 @@ static int buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, | |||
719 | if (fh->fmt == NULL) | 719 | if (fh->fmt == NULL) |
720 | return -EINVAL; | 720 | return -EINVAL; |
721 | 721 | ||
722 | if ((fh->width < norm_minw(fh->dev->vdev[fh->channel])) || | 722 | if ((fh->width < norm_minw(&fh->dev->vdev[fh->channel])) || |
723 | (fh->width > norm_maxw(fh->dev->vdev[fh->channel])) || | 723 | (fh->width > norm_maxw(&fh->dev->vdev[fh->channel])) || |
724 | (fh->height < norm_minh(fh->dev->vdev[fh->channel])) || | 724 | (fh->height < norm_minh(&fh->dev->vdev[fh->channel])) || |
725 | (fh->height > norm_maxh(fh->dev->vdev[fh->channel]))) { | 725 | (fh->height > norm_maxh(&fh->dev->vdev[fh->channel]))) { |
726 | dprintk(4, "invalid buffer prepare\n"); | 726 | dprintk(4, "invalid buffer prepare\n"); |
727 | return -EINVAL; | 727 | return -EINVAL; |
728 | } | 728 | } |
@@ -896,7 +896,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | |||
896 | int is_ntsc; | 896 | int is_ntsc; |
897 | 897 | ||
898 | is_ntsc = | 898 | is_ntsc = |
899 | (dev->vdev[fh->channel]->current_norm & V4L2_STD_NTSC) ? 1 : 0; | 899 | (dev->vdev[fh->channel].current_norm & V4L2_STD_NTSC) ? 1 : 0; |
900 | 900 | ||
901 | fmt = format_by_fourcc(f->fmt.pix.pixelformat); | 901 | fmt = format_by_fourcc(f->fmt.pix.pixelformat); |
902 | 902 | ||
@@ -1029,9 +1029,9 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
1029 | fh->height = f->fmt.pix.height; | 1029 | fh->height = f->fmt.pix.height; |
1030 | fh->vb_vidq.field = f->fmt.pix.field; | 1030 | fh->vb_vidq.field = f->fmt.pix.field; |
1031 | fh->type = f->type; | 1031 | fh->type = f->type; |
1032 | norm = norm_minw(fh->dev->vdev[fh->channel]); | 1032 | norm = norm_minw(&fh->dev->vdev[fh->channel]); |
1033 | if (fh->width > norm_minw(fh->dev->vdev[fh->channel])) { | 1033 | if (fh->width > norm_minw(&fh->dev->vdev[fh->channel])) { |
1034 | if (fh->height > norm_minh(fh->dev->vdev[fh->channel])) { | 1034 | if (fh->height > norm_minh(&fh->dev->vdev[fh->channel])) { |
1035 | if (fh->dev->cap_parm[fh->channel].capturemode & | 1035 | if (fh->dev->cap_parm[fh->channel].capturemode & |
1036 | V4L2_MODE_HIGHQUALITY) { | 1036 | V4L2_MODE_HIGHQUALITY) { |
1037 | fh->mode.scale = SCALE_4CIFSI; | 1037 | fh->mode.scale = SCALE_4CIFSI; |
@@ -1755,7 +1755,7 @@ static int s2255_open(struct file *file) | |||
1755 | video_device_node_name(vdev)); | 1755 | video_device_node_name(vdev)); |
1756 | lock_kernel(); | 1756 | lock_kernel(); |
1757 | for (i = 0; i < MAX_CHANNELS; i++) | 1757 | for (i = 0; i < MAX_CHANNELS; i++) |
1758 | if (dev->vdev[i] == vdev) { | 1758 | if (&dev->vdev[i] == vdev) { |
1759 | cur_channel = i; | 1759 | cur_channel = i; |
1760 | break; | 1760 | break; |
1761 | } | 1761 | } |
@@ -1985,7 +1985,6 @@ static const struct v4l2_ioctl_ops s2255_ioctl_ops = { | |||
1985 | static void s2255_video_device_release(struct video_device *vdev) | 1985 | static void s2255_video_device_release(struct video_device *vdev) |
1986 | { | 1986 | { |
1987 | struct s2255_dev *dev = video_get_drvdata(vdev); | 1987 | struct s2255_dev *dev = video_get_drvdata(vdev); |
1988 | video_device_release(vdev); | ||
1989 | kref_put(&dev->kref, s2255_destroy); | 1988 | kref_put(&dev->kref, s2255_destroy); |
1990 | return; | 1989 | return; |
1991 | } | 1990 | } |
@@ -2012,19 +2011,18 @@ static int s2255_probe_v4l(struct s2255_dev *dev) | |||
2012 | dev->vidq[i].dev = dev; | 2011 | dev->vidq[i].dev = dev; |
2013 | dev->vidq[i].channel = i; | 2012 | dev->vidq[i].channel = i; |
2014 | /* register 4 video devices */ | 2013 | /* register 4 video devices */ |
2015 | dev->vdev[i] = video_device_alloc(); | 2014 | memcpy(&dev->vdev[i], &template, sizeof(struct video_device)); |
2016 | memcpy(dev->vdev[i], &template, sizeof(struct video_device)); | 2015 | dev->vdev[i].parent = &dev->interface->dev; |
2017 | dev->vdev[i]->parent = &dev->interface->dev; | 2016 | video_set_drvdata(&dev->vdev[i], dev); |
2018 | video_set_drvdata(dev->vdev[i], dev); | ||
2019 | if (video_nr == -1) | 2017 | if (video_nr == -1) |
2020 | ret = video_register_device(dev->vdev[i], | 2018 | ret = video_register_device(&dev->vdev[i], |
2021 | VFL_TYPE_GRABBER, | 2019 | VFL_TYPE_GRABBER, |
2022 | video_nr); | 2020 | video_nr); |
2023 | else | 2021 | else |
2024 | ret = video_register_device(dev->vdev[i], | 2022 | ret = video_register_device(&dev->vdev[i], |
2025 | VFL_TYPE_GRABBER, | 2023 | VFL_TYPE_GRABBER, |
2026 | cur_nr + i); | 2024 | cur_nr + i); |
2027 | video_set_drvdata(dev->vdev[i], dev); | 2025 | video_set_drvdata(&dev->vdev[i], dev); |
2028 | 2026 | ||
2029 | if (ret != 0) { | 2027 | if (ret != 0) { |
2030 | dev_err(&dev->udev->dev, | 2028 | dev_err(&dev->udev->dev, |
@@ -2721,8 +2719,8 @@ static int s2255_probe(struct usb_interface *interface, | |||
2721 | return 0; | 2719 | return 0; |
2722 | errorV4L: | 2720 | errorV4L: |
2723 | for (i = 0; i < MAX_CHANNELS; i++) | 2721 | for (i = 0; i < MAX_CHANNELS; i++) |
2724 | if (dev->vdev[i] && video_is_registered(dev->vdev[i])) | 2722 | if (video_is_registered(&dev->vdev[i])) |
2725 | video_unregister_device(dev->vdev[i]); | 2723 | video_unregister_device(&dev->vdev[i]); |
2726 | errorBOARDINIT: | 2724 | errorBOARDINIT: |
2727 | s2255_board_shutdown(dev); | 2725 | s2255_board_shutdown(dev); |
2728 | errorFWMARKER: | 2726 | errorFWMARKER: |
@@ -2755,8 +2753,8 @@ static void s2255_disconnect(struct usb_interface *interface) | |||
2755 | dev = usb_get_intfdata(interface); | 2753 | dev = usb_get_intfdata(interface); |
2756 | /* unregister each video device. */ | 2754 | /* unregister each video device. */ |
2757 | for (i = 0; i < MAX_CHANNELS; i++) | 2755 | for (i = 0; i < MAX_CHANNELS; i++) |
2758 | if (video_is_registered(dev->vdev[i])) | 2756 | if (video_is_registered(&dev->vdev[i])) |
2759 | video_unregister_device(dev->vdev[i]); | 2757 | video_unregister_device(&dev->vdev[i]); |
2760 | /* wake up any of our timers */ | 2758 | /* wake up any of our timers */ |
2761 | atomic_set(&dev->fw_data->fw_state, S2255_FW_DISCONNECTING); | 2759 | atomic_set(&dev->fw_data->fw_state, S2255_FW_DISCONNECTING); |
2762 | wake_up(&dev->fw_data->wait_fw); | 2760 | wake_up(&dev->fw_data->wait_fw); |