[PATCH 5/14] pcmcia: check for invalid crc32 hashes in id_tables

Dominik Brodowski linux at dominikbrodowski.net
Sun Feb 27 05:11:29 EST 2005


Check for invalid crc32 hashes in drivers' id_tables if CONFIG_PCMCIA_DEBUG
is set.

Signed-off-by: Dominik Brodowski <linux at dominikbrodowski.net>
---

 drivers/pcmcia/ds.c |   37 +++++++++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+)

Index: 2.6.11-rc4/drivers/pcmcia/ds.c
===================================================================
--- 2.6.11-rc4.orig/drivers/pcmcia/ds.c	2005-02-16 21:22:33.000000000 +0100
+++ 2.6.11-rc4/drivers/pcmcia/ds.c	2005-02-16 21:22:59.000000000 +0100
@@ -260,6 +260,41 @@
 }
 EXPORT_SYMBOL(cs_error);
 
+#ifdef CONFIG_PCMCIA_DEBUG
+
+
+static void pcmcia_check_driver(struct pcmcia_driver *p_drv)
+{
+	struct pcmcia_device_id *did = p_drv->id_table;
+	unsigned int i;
+	u32 hash;
+
+	while (did && did->match_flags) {
+		for (i=0; i<4; i++) {
+			if (!did->prod_id[i])
+				continue;
+
+			hash = crc32(0, did->prod_id[i], strlen(did->prod_id[i]));
+			if (hash == did->prod_id_hash[i])
+				continue;
+
+			printk(KERN_DEBUG "pcmcia: %s: invalid hash for "
+			       "product string \"%s\": is 0x%x, should "
+			       "be 0x%x\n", p_drv->drv.name, did->prod_id[i],
+			       did->prod_id_hash[i], hash);
+		}
+		did++;
+	}
+
+	return;
+}
+
+#else
+static inline void pcmcia_check_driver(struct pcmcia_driver *p_drv) {
+	return;
+}
+#endif
+
 /*======================================================================*/
 
 static struct pcmcia_driver * get_pcmcia_driver (dev_info_t *dev_info);
@@ -296,6 +331,8 @@
 	if (!driver)
 		return -EINVAL;
 
+	pcmcia_check_driver(driver);
+
 	/* initialize common fields */
 	driver->drv.bus = &pcmcia_bus_type;
 	driver->drv.owner = driver->owner;



More information about the linux-pcmcia mailing list