Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cdaa898b authored by Tomas Winkler's avatar Tomas Winkler Committed by Greg Kroah-Hartman
Browse files

staging/easycap: kill telltale logic



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: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent cbbd8a58
Loading
Loading
Loading
Loading
+0 −2
Original line number Original line Diff line number Diff line
@@ -280,8 +280,6 @@ struct inputset {
 */
 */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
struct easycap {
struct easycap {
#define TELLTALE "expectedstring"
	char telltale[16];
	int isdongle;
	int isdongle;
	int minor;
	int minor;


+0 −10
Original line number Original line Diff line number Diff line
@@ -967,10 +967,6 @@ long easycap_unlocked_ioctl(struct file *file,
		SAY("ERROR:  peasycap is NULL\n");
		SAY("ERROR:  peasycap is NULL\n");
		return -1;
		return -1;
	}
	}
	if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
		SAY("ERROR: bad peasycap\n");
		return -EFAULT;
	}
	p = peasycap->pusb_device;
	p = peasycap->pusb_device;
	if (!p) {
	if (!p) {
		SAM("ERROR: peasycap->pusb_device is NULL\n");
		SAM("ERROR: peasycap->pusb_device is NULL\n");
@@ -1004,12 +1000,6 @@ long easycap_unlocked_ioctl(struct file *file,
			mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
			mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
			return -ERESTARTSYS;
			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) {
		if (!peasycap->pusb_device) {
			SAM("ERROR: peasycap->pusb_device is NULL\n");
			SAM("ERROR: peasycap->pusb_device is NULL\n");
			mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
			mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
+3 −81
Original line number Original line Diff line number Diff line
@@ -158,10 +158,6 @@ static int easycap_open(struct inode *inode, struct file *file)
		SAY("ERROR: peasycap is NULL\n");
		SAY("ERROR: peasycap is NULL\n");
		return -EFAULT;
		return -EFAULT;
	}
	}
	if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
		SAY("ERROR: bad peasycap: %p\n", peasycap);
		return -EFAULT;
	}
	if (!peasycap->pusb_device) {
	if (!peasycap->pusb_device) {
		SAM("ERROR: peasycap->pusb_device is NULL\n");
		SAM("ERROR: peasycap->pusb_device is NULL\n");
		return -EFAULT;
		return -EFAULT;
@@ -695,10 +691,6 @@ static int videodev_release(struct video_device *pvideo_device)
		SAY("ending unsuccessfully\n");
		SAY("ending unsuccessfully\n");
		return -EFAULT;
		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)) {
	if (0 != kill_video_urbs(peasycap)) {
		SAM("ERROR: kill_video_urbs() failed\n");
		SAM("ERROR: kill_video_urbs() failed\n");
		return -EFAULT;
		return -EFAULT;
@@ -736,10 +728,6 @@ static void easycap_delete(struct kref *pkref)
		SAM("ERROR: peasycap is NULL: cannot perform deletions\n");
		SAM("ERROR: peasycap is NULL: cannot perform deletions\n");
		return;
		return;
	}
	}
	if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
		SAY("ERROR: bad peasycap: %p\n", peasycap);
		return;
	}
	kd = isdongle(peasycap);
	kd = isdongle(peasycap);
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*
/*
@@ -962,10 +950,6 @@ static unsigned int easycap_poll(struct file *file, poll_table *wait)
		SAY("ERROR:  peasycap is NULL\n");
		SAY("ERROR:  peasycap is NULL\n");
		return -EFAULT;
		return -EFAULT;
	}
	}
	if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
		SAY("ERROR: bad peasycap: %p\n", peasycap);
		return -EFAULT;
	}
	if (!peasycap->pusb_device) {
	if (!peasycap->pusb_device) {
		SAY("ERROR:  peasycap->pusb_device is NULL\n");
		SAY("ERROR:  peasycap->pusb_device is NULL\n");
		return -EFAULT;
		return -EFAULT;
@@ -996,11 +980,6 @@ static unsigned int easycap_poll(struct file *file, poll_table *wait)
			mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
			mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
			return -ERESTARTSYS;
			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) {
		if (!peasycap->pusb_device) {
			SAM("ERROR: peasycap->pusb_device is NULL\n");
			SAM("ERROR: peasycap->pusb_device is NULL\n");
			mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
			mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
@@ -2455,10 +2434,6 @@ static void easycap_vma_open(struct vm_area_struct *pvma)
		SAY("ERROR: peasycap is NULL\n");
		SAY("ERROR: peasycap is NULL\n");
		return;
		return;
	}
	}
	if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
		SAY("ERROR: bad peasycap: %p\n", peasycap);
		return;
	}
	peasycap->vma_many++;
	peasycap->vma_many++;
	JOT(8, "%i=peasycap->vma_many\n", peasycap->vma_many);
	JOT(8, "%i=peasycap->vma_many\n", peasycap->vma_many);
	return;
	return;
@@ -2473,10 +2448,6 @@ static void easycap_vma_close(struct vm_area_struct *pvma)
		SAY("ERROR: peasycap is NULL\n");
		SAY("ERROR: peasycap is NULL\n");
		return;
		return;
	}
	}
	if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
		SAY("ERROR: bad peasycap: %p\n", peasycap);
		return;
	}
	peasycap->vma_many--;
	peasycap->vma_many--;
	JOT(8, "%i=peasycap->vma_many\n", peasycap->vma_many);
	JOT(8, "%i=peasycap->vma_many\n", peasycap->vma_many);
	return;
	return;
@@ -2607,10 +2578,6 @@ static void easycap_complete(struct urb *purb)
		SAY("ERROR: easycap_complete(): peasycap is NULL\n");
		SAY("ERROR: easycap_complete(): peasycap is NULL\n");
		return;
		return;
	}
	}
	if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
		SAY("ERROR: bad peasycap: %p\n", peasycap);
		return;
	}
	if (peasycap->video_eof)
	if (peasycap->video_eof)
		return;
		return;
	for (i = 0; i < VIDEO_ISOC_BUFFER_MANY; i++)
	for (i = 0; i < VIDEO_ISOC_BUFFER_MANY; i++)
@@ -3001,7 +2968,6 @@ static int easycap_usb_probe(struct usb_interface *intf,
	struct easycap_format *peasycap_format;
	struct easycap_format *peasycap_format;
	int fmtidx;
	int fmtidx;
	struct inputset *inputset;
	struct inputset *inputset;
	struct v4l2_device *pv4l2_device;


	usbdev = interface_to_usbdev(intf);
	usbdev = interface_to_usbdev(intf);


@@ -3055,7 +3021,6 @@ static int easycap_usb_probe(struct usb_interface *intf,
*/
*/
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
		peasycap->minor = -1;
		peasycap->minor = -1;
		strcpy(&peasycap->telltale[0], TELLTALE);
		kref_init(&peasycap->kref);
		kref_init(&peasycap->kref);
		JOM(8, "intf[%i]: after kref_init(..._video) "
		JOM(8, "intf[%i]: after kref_init(..._video) "
				"%i=peasycap->kref.refcount.counter\n",
				"%i=peasycap->kref.refcount.counter\n",
@@ -3268,23 +3233,6 @@ static int easycap_usb_probe(struct usb_interface *intf,
								bInterfaceNumber);
								bInterfaceNumber);
			return -ENODEV;
			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) ||
	if ((USB_CLASS_VIDEO == bInterfaceClass) ||
@@ -3776,14 +3724,12 @@ static int easycap_usb_probe(struct usb_interface *intf,
 *  THE VIDEO DEVICE CAN BE REGISTERED NOW, AS IT IS READY.
 *  THE VIDEO DEVICE CAN BE REGISTERED NOW, AS IT IS READY.
 */
 */
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
		if (0 != (v4l2_device_register(&(intf->dev),
		if (v4l2_device_register(&intf->dev, &peasycap->v4l2_device)) {
							&(peasycap->v4l2_device)))) {
			SAM("v4l2_device_register() failed\n");
			SAM("v4l2_device_register() failed\n");
			return -ENODEV;
			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
 *                                 FIXME
@@ -4160,7 +4106,6 @@ static void easycap_usb_disconnect(struct usb_interface *pusb_interface)
	struct list_head *plist_head;
	struct list_head *plist_head;
	struct data_urb *pdata_urb;
	struct data_urb *pdata_urb;
	int minor, m, kd;
	int minor, m, kd;
	struct v4l2_device *pv4l2_device;


	JOT(4, "\n");
	JOT(4, "\n");


@@ -4187,29 +4132,6 @@ static void easycap_usb_disconnect(struct usb_interface *pusb_interface)
		return;
		return;
	}
	}
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*
 *  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.
 *  IF THE WAIT QUEUES ARE NOT CLEARED A DEADLOCK IS POSSIBLE.  BEWARE.
*/
*/
+0 −29
Original line number Original line Diff line number Diff line
@@ -92,10 +92,6 @@ easycap_alsa_complete(struct urb *purb)
		SAY("ERROR: peasycap is NULL\n");
		SAY("ERROR: peasycap is NULL\n");
		return;
		return;
	}
	}
	if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
		SAY("ERROR: bad peasycap\n");
		return;
	}
	much = 0;
	much = 0;
	if (peasycap->audio_idle) {
	if (peasycap->audio_idle) {
		JOM(16, "%i=audio_idle  %i=audio_isoc_streaming\n",
		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");
		SAY("ERROR:  peasycap is NULL\n");
		return -EFAULT;
		return -EFAULT;
	}
	}
	if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
		SAY("ERROR: bad peasycap\n");
		return -EFAULT;
	}
	if (peasycap->psnd_card != psnd_card) {
	if (peasycap->psnd_card != psnd_card) {
		SAM("ERROR: bad peasycap->psnd_card\n");
		SAM("ERROR: bad peasycap->psnd_card\n");
		return -EFAULT;
		return -EFAULT;
@@ -350,10 +342,6 @@ static int easycap_alsa_close(struct snd_pcm_substream *pss)
		SAY("ERROR:  peasycap is NULL\n");
		SAY("ERROR:  peasycap is NULL\n");
		return -EFAULT;
		return -EFAULT;
	}
	}
	if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
		SAY("ERROR: bad peasycap\n");
		return -EFAULT;
	}
	pss->private_data = NULL;
	pss->private_data = NULL;
	peasycap->psubstream = NULL;
	peasycap->psubstream = NULL;
	JOT(4, "ending successfully\n");
	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");
		SAY("ERROR:  peasycap is NULL\n");
		return -EFAULT;
		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 %8i Hz=rate\n", pss->runtime->rate);
	JOM(16, "ALSA decides %8ld =period_size\n", pss->runtime->period_size);
	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");
		SAY("ERROR:  peasycap is NULL\n");
		return -EFAULT;
		return -EFAULT;
	}
	}
	if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
		SAY("ERROR: bad peasycap\n");
		return -EFAULT;
	}

	switch (cmd) {
	switch (cmd) {
	case SNDRV_PCM_TRIGGER_START: {
	case SNDRV_PCM_TRIGGER_START: {
		peasycap->audio_idle = 0;
		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");
		SAY("ERROR:  peasycap is NULL\n");
		return -EFAULT;
		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)) {
	if ((0 != peasycap->audio_eof) || (0 != peasycap->audio_idle)) {
		JOM(8, "returning -EIO because  "
		JOM(8, "returning -EIO because  "
		    "%i=audio_idle  %i=audio_eof\n",
		    "%i=audio_idle  %i=audio_eof\n",
@@ -584,10 +559,6 @@ int easycap_alsa_probe(struct easycap *peasycap)
		SAY("ERROR: peasycap is NULL\n");
		SAY("ERROR: peasycap is NULL\n");
		return -ENODEV;
		return -ENODEV;
	}
	}
	if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
		SAY("ERROR: bad peasycap\n");
		return -EFAULT;
	}
	if (0 > peasycap->minor) {
	if (0 > peasycap->minor) {
		SAY("ERROR: no minor\n");
		SAY("ERROR: no minor\n");
		return -ENODEV;
		return -ENODEV;