This reason for this feature was 'some versions of the videodev module overwrite the data which has been written by the call to usb_set_intfdata() in easycap_usb_probe(), replacing it with a pointer to the embedded v4l2_device structure. to detect this, the string in the easycap.telltale[] buffer is checked.' The upstream version of v4l2_device_register sets driver data only when it wasn't already set, therefore this is not needed Signed-off-by: Tomas Winkler <tomas.winkler@xxxxxxxxx> --- V2: lowercase the quotation in the commit message drivers/staging/easycap/easycap.h | 2 - drivers/staging/easycap/easycap_ioctl.c | 10 ---- drivers/staging/easycap/easycap_main.c | 84 +----------------------------- drivers/staging/easycap/easycap_sound.c | 29 ----------- 4 files changed, 3 insertions(+), 122 deletions(-) diff --git a/drivers/staging/easycap/easycap.h b/drivers/staging/easycap/easycap.h index 1f94e23..b69df18 100644 --- a/drivers/staging/easycap/easycap.h +++ b/drivers/staging/easycap/easycap.h @@ -285,8 +285,6 @@ struct inputset { */ /*---------------------------------------------------------------------------*/ struct easycap { -#define TELLTALE "expectedstring" - char telltale[16]; int isdongle; int minor; diff --git a/drivers/staging/easycap/easycap_ioctl.c b/drivers/staging/easycap/easycap_ioctl.c index b3bd11d..c5a5b60 100644 --- a/drivers/staging/easycap/easycap_ioctl.c +++ b/drivers/staging/easycap/easycap_ioctl.c @@ -966,10 +966,6 @@ long easycap_unlocked_ioctl(struct file *file, SAY("ERROR: peasycap is NULL\n"); return -1; } - if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { - SAY("ERROR: bad peasycap\n"); - return -EFAULT; - } p = peasycap->pusb_device; if (!p) { SAM("ERROR: peasycap->pusb_device is NULL\n"); @@ -1003,12 +999,6 @@ long easycap_unlocked_ioctl(struct file *file, mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -ERESTARTSYS; } - if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { - SAY("ERROR: bad peasycap\n"); - mutex_unlock(&easycapdc60_dongle[kd].mutex_video); - return -EFAULT; - } - p = peasycap->pusb_device; if (!peasycap->pusb_device) { SAM("ERROR: peasycap->pusb_device is NULL\n"); mutex_unlock(&easycapdc60_dongle[kd].mutex_video); diff --git a/drivers/staging/easycap/easycap_main.c b/drivers/staging/easycap/easycap_main.c index 62e07f6..cd7f106 100644 --- a/drivers/staging/easycap/easycap_main.c +++ b/drivers/staging/easycap/easycap_main.c @@ -158,10 +158,6 @@ static int easycap_open(struct inode *inode, struct file *file) SAY("ERROR: peasycap is NULL\n"); return -EFAULT; } - if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { - SAY("ERROR: bad peasycap: %p\n", peasycap); - return -EFAULT; - } if (!peasycap->pusb_device) { SAM("ERROR: peasycap->pusb_device is NULL\n"); return -EFAULT; @@ -695,10 +691,6 @@ static int videodev_release(struct video_device *pvideo_device) SAY("ending unsuccessfully\n"); return -EFAULT; } - if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { - SAY("ERROR: bad peasycap: %p\n", peasycap); - return -EFAULT; - } if (0 != kill_video_urbs(peasycap)) { SAM("ERROR: kill_video_urbs() failed\n"); return -EFAULT; @@ -736,10 +728,6 @@ static void easycap_delete(struct kref *pkref) SAM("ERROR: peasycap is NULL: cannot perform deletions\n"); return; } - if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { - SAY("ERROR: bad peasycap: %p\n", peasycap); - return; - } kd = isdongle(peasycap); /*---------------------------------------------------------------------------*/ /* @@ -961,10 +949,6 @@ static unsigned int easycap_poll(struct file *file, poll_table *wait) SAY("ERROR: peasycap is NULL\n"); return -EFAULT; } - if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { - SAY("ERROR: bad peasycap: %p\n", peasycap); - return -EFAULT; - } if (!peasycap->pusb_device) { SAY("ERROR: peasycap->pusb_device is NULL\n"); return -EFAULT; @@ -995,11 +979,6 @@ static unsigned int easycap_poll(struct file *file, poll_table *wait) mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -ERESTARTSYS; } - if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { - SAY("ERROR: bad peasycap: %p\n", peasycap); - mutex_unlock(&easycapdc60_dongle[kd].mutex_video); - return -ERESTARTSYS; - } if (!peasycap->pusb_device) { SAM("ERROR: peasycap->pusb_device is NULL\n"); mutex_unlock(&easycapdc60_dongle[kd].mutex_video); @@ -2454,10 +2433,6 @@ static void easycap_vma_open(struct vm_area_struct *pvma) SAY("ERROR: peasycap is NULL\n"); return; } - if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { - SAY("ERROR: bad peasycap: %p\n", peasycap); - return; - } peasycap->vma_many++; JOT(8, "%i=peasycap->vma_many\n", peasycap->vma_many); return; @@ -2472,10 +2447,6 @@ static void easycap_vma_close(struct vm_area_struct *pvma) SAY("ERROR: peasycap is NULL\n"); return; } - if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { - SAY("ERROR: bad peasycap: %p\n", peasycap); - return; - } peasycap->vma_many--; JOT(8, "%i=peasycap->vma_many\n", peasycap->vma_many); return; @@ -2606,10 +2577,6 @@ static void easycap_complete(struct urb *purb) SAY("ERROR: easycap_complete(): peasycap is NULL\n"); return; } - if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { - SAY("ERROR: bad peasycap: %p\n", peasycap); - return; - } if (peasycap->video_eof) return; for (i = 0; i < VIDEO_ISOC_BUFFER_MANY; i++) @@ -3000,7 +2967,6 @@ static int easycap_usb_probe(struct usb_interface *intf, struct easycap_format *peasycap_format; int fmtidx; struct inputset *inputset; - struct v4l2_device *pv4l2_device; usbdev = interface_to_usbdev(intf); @@ -3054,7 +3020,6 @@ static int easycap_usb_probe(struct usb_interface *intf, */ /*---------------------------------------------------------------------------*/ peasycap->minor = -1; - strcpy(&peasycap->telltale[0], TELLTALE); kref_init(&peasycap->kref); JOM(8, "intf[%i]: after kref_init(..._video) " "%i=peasycap->kref.refcount.counter\n", @@ -3267,23 +3232,6 @@ static int easycap_usb_probe(struct usb_interface *intf, bInterfaceNumber); return -ENODEV; } -/*---------------------------------------------------------------------------*/ -/* - * SOME VERSIONS OF THE videodev MODULE OVERWRITE THE DATA WHICH HAS - * BEEN WRITTEN BY THE CALL TO usb_set_intfdata() IN easycap_usb_probe(), - * REPLACING IT WITH A POINTER TO THE EMBEDDED v4l2_device STRUCTURE. - * TO DETECT THIS, THE STRING IN THE easycap.telltale[] BUFFER IS CHECKED. -*/ -/*---------------------------------------------------------------------------*/ - if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { - pv4l2_device = usb_get_intfdata(intf); - if (!pv4l2_device) { - SAY("ERROR: pv4l2_device is NULL\n"); - return -ENODEV; - } - peasycap = (struct easycap *) - container_of(pv4l2_device, struct easycap, v4l2_device); - } } /*---------------------------------------------------------------------------*/ if ((USB_CLASS_VIDEO == bInterfaceClass) || @@ -3775,14 +3723,12 @@ static int easycap_usb_probe(struct usb_interface *intf, * THE VIDEO DEVICE CAN BE REGISTERED NOW, AS IT IS READY. */ /*--------------------------------------------------------------------------*/ - if (0 != (v4l2_device_register(&(intf->dev), - &(peasycap->v4l2_device)))) { + if (v4l2_device_register(&intf->dev, &peasycap->v4l2_device)) { SAM("v4l2_device_register() failed\n"); return -ENODEV; - } else { - JOM(4, "registered device instance: %s\n", - &(peasycap->v4l2_device.name[0])); } + JOM(4, "registered device instance: %s\n", + peasycap->v4l2_device.name); /*---------------------------------------------------------------------------*/ /* * FIXME @@ -4159,7 +4105,6 @@ static void easycap_usb_disconnect(struct usb_interface *pusb_interface) struct list_head *plist_head; struct data_urb *pdata_urb; int minor, m, kd; - struct v4l2_device *pv4l2_device; JOT(4, "\n"); @@ -4187,29 +4132,6 @@ static void easycap_usb_disconnect(struct usb_interface *pusb_interface) } /*---------------------------------------------------------------------------*/ /* - * SOME VERSIONS OF THE videodev MODULE OVERWRITE THE DATA WHICH HAS - * BEEN WRITTEN BY THE CALL TO usb_set_intfdata() IN easycap_usb_probe(), - * REPLACING IT WITH A POINTER TO THE EMBEDDED v4l2_device STRUCTURE. - * TO DETECT THIS, THE STRING IN THE easycap.telltale[] BUFFER IS CHECKED. -*/ -/*---------------------------------------------------------------------------*/ - if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { - pv4l2_device = usb_get_intfdata(pusb_interface); - if (!pv4l2_device) { - SAY("ERROR: pv4l2_device is NULL\n"); - return; - } - peasycap = (struct easycap *) - container_of(pv4l2_device, struct easycap, v4l2_device); - } -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ -/*---------------------------------------------------------------------------*/ - if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { - SAY("ERROR: bad peasycap: %p\n", peasycap); - return; - } -/*---------------------------------------------------------------------------*/ -/* * IF THE WAIT QUEUES ARE NOT CLEARED A DEADLOCK IS POSSIBLE. BEWARE. */ /*---------------------------------------------------------------------------*/ diff --git a/drivers/staging/easycap/easycap_sound.c b/drivers/staging/easycap/easycap_sound.c index a3402b0..9218d81 100644 --- a/drivers/staging/easycap/easycap_sound.c +++ b/drivers/staging/easycap/easycap_sound.c @@ -92,10 +92,6 @@ easycap_alsa_complete(struct urb *purb) SAY("ERROR: peasycap is NULL\n"); return; } - if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { - SAY("ERROR: bad peasycap\n"); - return; - } much = 0; if (peasycap->audio_idle) { JOM(16, "%i=audio_idle %i=audio_isoc_streaming\n", @@ -310,10 +306,6 @@ static int easycap_alsa_open(struct snd_pcm_substream *pss) SAY("ERROR: peasycap is NULL\n"); return -EFAULT; } - if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { - SAY("ERROR: bad peasycap\n"); - return -EFAULT; - } if (peasycap->psnd_card != psnd_card) { SAM("ERROR: bad peasycap->psnd_card\n"); return -EFAULT; @@ -350,10 +342,6 @@ static int easycap_alsa_close(struct snd_pcm_substream *pss) SAY("ERROR: peasycap is NULL\n"); return -EFAULT; } - if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { - SAY("ERROR: bad peasycap\n"); - return -EFAULT; - } pss->private_data = NULL; peasycap->psubstream = NULL; JOT(4, "ending successfully\n"); @@ -441,10 +429,6 @@ static int easycap_alsa_prepare(struct snd_pcm_substream *pss) SAY("ERROR: peasycap is NULL\n"); return -EFAULT; } - if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { - SAY("ERROR: bad peasycap\n"); - return -EFAULT; - } JOM(16, "ALSA decides %8i Hz=rate\n", pss->runtime->rate); JOM(16, "ALSA decides %8ld =period_size\n", pss->runtime->period_size); @@ -488,11 +472,6 @@ static int easycap_alsa_trigger(struct snd_pcm_substream *pss, int cmd) SAY("ERROR: peasycap is NULL\n"); return -EFAULT; } - if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { - SAY("ERROR: bad peasycap\n"); - return -EFAULT; - } - switch (cmd) { case SNDRV_PCM_TRIGGER_START: { peasycap->audio_idle = 0; @@ -523,10 +502,6 @@ static snd_pcm_uframes_t easycap_alsa_pointer(struct snd_pcm_substream *pss) SAY("ERROR: peasycap is NULL\n"); return -EFAULT; } - if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { - SAY("ERROR: bad peasycap\n"); - return -EFAULT; - } if ((0 != peasycap->audio_eof) || (0 != peasycap->audio_idle)) { JOM(8, "returning -EIO because " "%i=audio_idle %i=audio_eof\n", @@ -584,10 +559,6 @@ int easycap_alsa_probe(struct easycap *peasycap) SAY("ERROR: peasycap is NULL\n"); return -ENODEV; } - if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { - SAY("ERROR: bad peasycap\n"); - return -EFAULT; - } if (0 > peasycap->minor) { SAY("ERROR: no minor\n"); return -ENODEV; -- 1.7.4.4 --------------------------------------------------------------------- Intel Israel (74) Limited This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/devel