The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] Chardev checking of overlapping ranges is incorrect.
@ 2006-08-07 22:55 Linas Vepstas
  2006-08-07 23:00 ` Linas Vepstas
  2006-08-08  6:47 ` Andrew Morton
  0 siblings, 2 replies; 8+ messages in thread
From: Linas Vepstas @ 2006-08-07 22:55 UTC (permalink / raw)
  To: Alan Cox, rubini, device; +Cc: linux-kernel



The current code in register_chrdev_region() attempts to check 
for overlapping regions of minor device numbers, but performs 
that check incorrectly. For example, if a device with minor 
numbers 128, 129, 130 is registered first, and a device with 
minor number 3,4,5 is registered later, then the later range
is incorrectly identified as "overlapping" (since 130>3), 
when clearly this is the wrong conclusion.

This patch fixes the overlap check to work correctly.

Signed-off-by: Signed-off-by: Linas Vepstas <linas@austin.ibm.com>

----
 fs/char_dev.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Index: linux-2.6.18-rc3-mm2/fs/char_dev.c
===================================================================
--- linux-2.6.18-rc3-mm2.orig/fs/char_dev.c	2006-08-07 17:16:53.000000000 -0500
+++ linux-2.6.18-rc3-mm2/fs/char_dev.c	2006-08-07 17:18:59.000000000 -0500
@@ -93,6 +93,7 @@ __register_chrdev_region(unsigned int ma
 		}
 
 		if (i == 0) {
+printk ("duude egister_chrdev_regio no major !!\n");
 			ret = -EBUSY;
 			goto out;
 		}
@@ -113,9 +114,13 @@ __register_chrdev_region(unsigned int ma
 		     (((*cp)->baseminor >= baseminor) ||
 		      ((*cp)->baseminor + (*cp)->minorct > baseminor))))
 			break;
+
+	/* Check for overlap of minor ranges */
 	if (*cp && (*cp)->major == major &&
-	    (((*cp)->baseminor < baseminor + minorct) ||
-	     ((*cp)->baseminor + (*cp)->minorct > baseminor))) {
+	    ((((*cp)->baseminor <= baseminor) &&
+		   ((*cp)->baseminor + (*cp)->minorct >= baseminor)) ||
+	     (((*cp)->baseminor >= baseminor) &&
+	      ((*cp)->baseminor <= baseminor+minorct)))) {
 		ret = -EBUSY;
 		goto out;
 	}

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-08-09 17:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-07 22:55 [PATCH] Chardev checking of overlapping ranges is incorrect Linas Vepstas
2006-08-07 23:00 ` Linas Vepstas
2006-08-08  6:47 ` Andrew Morton
2006-08-08 20:52   ` Amos Waterland
2006-08-08 21:33     ` Linas Vepstas
2006-08-08 22:20       ` Amos Waterland
2006-08-09  1:15         ` Linas Vepstas
2006-08-09 17:06           ` Amos Waterland

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox