diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2005-06-27 19:28:07 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-27 21:03:06 -0400 |
commit | 23a83bfe6ab51c745d109d979c78a96fe3e93f5c (patch) | |
tree | 32f7e48ab0eb18966c709880747d8ed1c616e4a2 | |
parent | 1ad275e3e7d253d44f03868e85977c908e334fed (diff) |
[PATCH] pcmcia: check for invalid crc32 hashes in id_tables
Check for invalid crc32 hashes in drivers' id_tables if CONFIG_PCMCIA_DEBUG is
set.
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | drivers/pcmcia/ds.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 5701b93b2ddb..3ac7a443f668 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c | |||
@@ -260,6 +260,41 @@ void cs_error(client_handle_t handle, int func, int ret) | |||
260 | } | 260 | } |
261 | EXPORT_SYMBOL(cs_error); | 261 | EXPORT_SYMBOL(cs_error); |
262 | 262 | ||
263 | #ifdef CONFIG_PCMCIA_DEBUG | ||
264 | |||
265 | |||
266 | static void pcmcia_check_driver(struct pcmcia_driver *p_drv) | ||
267 | { | ||
268 | struct pcmcia_device_id *did = p_drv->id_table; | ||
269 | unsigned int i; | ||
270 | u32 hash; | ||
271 | |||
272 | while (did && did->match_flags) { | ||
273 | for (i=0; i<4; i++) { | ||
274 | if (!did->prod_id[i]) | ||
275 | continue; | ||
276 | |||
277 | hash = crc32(0, did->prod_id[i], strlen(did->prod_id[i])); | ||
278 | if (hash == did->prod_id_hash[i]) | ||
279 | continue; | ||
280 | |||
281 | printk(KERN_DEBUG "pcmcia: %s: invalid hash for " | ||
282 | "product string \"%s\": is 0x%x, should " | ||
283 | "be 0x%x\n", p_drv->drv.name, did->prod_id[i], | ||
284 | did->prod_id_hash[i], hash); | ||
285 | } | ||
286 | did++; | ||
287 | } | ||
288 | |||
289 | return; | ||
290 | } | ||
291 | |||
292 | #else | ||
293 | static inline void pcmcia_check_driver(struct pcmcia_driver *p_drv) { | ||
294 | return; | ||
295 | } | ||
296 | #endif | ||
297 | |||
263 | /*======================================================================*/ | 298 | /*======================================================================*/ |
264 | 299 | ||
265 | static struct pcmcia_driver * get_pcmcia_driver (dev_info_t *dev_info); | 300 | static struct pcmcia_driver * get_pcmcia_driver (dev_info_t *dev_info); |
@@ -296,6 +331,8 @@ int pcmcia_register_driver(struct pcmcia_driver *driver) | |||
296 | if (!driver) | 331 | if (!driver) |
297 | return -EINVAL; | 332 | return -EINVAL; |
298 | 333 | ||
334 | pcmcia_check_driver(driver); | ||
335 | |||
299 | /* initialize common fields */ | 336 | /* initialize common fields */ |
300 | driver->drv.bus = &pcmcia_bus_type; | 337 | driver->drv.bus = &pcmcia_bus_type; |
301 | driver->drv.owner = driver->owner; | 338 | driver->drv.owner = driver->owner; |