lkml.org 
[lkml]   [2004]   [Apr]   [3]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 2.6.5rc2-mm2] Root_plug device check
FromFabian Frederick <>
DateSat, 03 Apr 2004 10:42:33 +0200
Hi,

      Here's a patch to check device in root_plug to avoid box freeze
when user gives bad ids.

Regards,
Fabian
diff -Naur orig/security/root_plug.c edited/security/root_plug.c
--- orig/security/root_plug.c	2004-03-25 23:54:19.000000000 +0100
+++ edited/security/root_plug.c	2004-03-26 23:39:26.000000000 +0100
@@ -20,6 +20,9 @@
  *	modify it under the terms of the GNU General Public License as
  *	published by the Free Software Foundation, version 2 of the
  *	License.
+ *
+ * 03/2004 : (Fabian Frederick) 
+ *		-Make sure we have device if defined through module call
  */
 
 #include <linux/config.h>
@@ -33,8 +36,11 @@
 static int secondary;
 
 /* default is a generic type of usb to serial converter */
-static int vendor_id = 0x0557;
-static int product_id = 0x2008;
+#define DEFAULT_VENDOR 0x0557
+#define DEFAULT_PRODUCT 0x2008
+
+static int vendor_id = DEFAULT_VENDOR;
+static int product_id = DEFAULT_PRODUCT;
 
 MODULE_PARM(vendor_id, "h");
 MODULE_PARM_DESC(vendor_id, "USB Vendor ID of device to look for");
@@ -101,6 +107,17 @@
 
 static int __init rootplug_init (void)
 {
+	struct usb_device *dev;
+
+	/* check we have device featuring in usb list to avoid any trouble*/
+	if((vendor_id!=DEFAULT_VENDOR) || (product_id!=DEFAULT_PRODUCT)){
+		dev = usb_find_device(vendor_id, product_id);
+		if (!dev) {
+			printk (KERN_INFO "Unable to find USB device "
+				" We won't start to avoid box freeze.\n");
+			return -EINVAL;
+		}
+	}
 	/* register ourselves with the security framework */
 	if (register_security (&rootplug_security_ops)) {
 		printk (KERN_INFO 
\
 
 \ /
  Last update: 2005-03-22 14:02    [from the cache]
©2003-2008