[PATCH] fix mos7840 in kernels >=2.6.26.3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch effectively fixes the bug #11585 [1] for me. It does so by
assigning minor number to device before calling attach() function. The
reason for this bug to appear is apparently that mos7840_startup()
function uses minor variable, which was unitialized at the moment. The
reason for this to appear now, but not earlier, is that mos7840 module
was supposedly tested only using just one device, for which case minor
was equal to the very same zero value before and after its
initialization. The TTY_NO_MINOR patch changed the initial value, and
that broke everything.

I can't check if this patch breaks other devices, because I don't have
any. Neither do I have enough experience to figure this out from reading
sources. So, please test.

PS: As far as I'm concerned the latest 2.6.28.7 kernel still has this
bug. The fix is the same but line numbers.


Links:
[1] http://bugzilla.kernel.org/show_bug.cgi?id=11585


Patch itself:

diff -uprN -X linux-2.6.26.8.orig/Documentation/dontdiff
linux-2.6.26.8.orig/drivers/usb/serial/usb-serial.c
linux-2.6.26.8/drivers/usb/serial/usb-serial.c
--- linux-2.6.26.8.orig/drivers/usb/serial/usb-serial.c	2009-03-05 12:01:05.000000000 +0600
+++ linux-2.6.26.8/drivers/usb/serial/usb-serial.c	2009-03-05 12:04:22.000000000 +0600
@@ -908,6 +908,13 @@ int usb_serial_probe(struct usb_interfac
 	} else if (num_interrupt_out) {
 		dbg("the device claims to support interrupt out transfers, but write_int_callback is not defined");
 	}
+
+	/* get minor before attaching the device */
+	if (get_free_serial (serial, num_ports, &minor) == NULL) {
+		dev_err(&interface->dev, "No more free serial devices\n");
+		goto probe_error;
+	}
+	serial->minor = minor;
 	
 	/* if this device type has an attach function, call it */
 	if (type->attach) {
@@ -926,12 +933,6 @@ int usb_serial_probe(struct usb_interfac
 		}
 	}

-	if (get_free_serial (serial, num_ports, &minor) == NULL) {
-		dev_err(&interface->dev, "No more free serial devices\n");
-		goto probe_error;
-	}
-	serial->minor = minor;
-
 	/* register all of the individual ports with the driver core */
 	for (i = 0; i < num_ports; ++i) {
 		port = serial->port[i];


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux