public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2.6.5rc2-mm2] Root_plug device check
@ 2004-04-03  8:42 Fabian Frederick
  2004-04-07 18:21 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Fabian Frederick @ 2004-04-03  8:42 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 117 bytes --]

Hi,

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

Regards,
Fabian

[-- Attachment #2: root_plug1.diff --]
[-- Type: text/x-patch, Size: 1466 bytes --]

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 

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

end of thread, other threads:[~2004-04-07 19:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-03  8:42 [PATCH 2.6.5rc2-mm2] Root_plug device check Fabian Frederick
2004-04-07 18:21 ` Greg KH

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