aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/cistpl.c
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2010-01-02 06:28:04 -0500
committerDominik Brodowski <linux@dominikbrodowski.net>2010-01-17 12:30:09 -0500
commit904e377744bfdcea276c27167fa6a609929f39dc (patch)
tree4dc05b84992a2c35a1933b5b12b44391e0cd4e08 /drivers/pcmcia/cistpl.c
parentfa0b3bc504ff813cc05988bb30bbb6c6a0263eb4 (diff)
pcmcia: validate CIS, not CIS cache.
In pccard_validate_cis(), validate the card CIS, not the CIS cache. Also, destroy the CIS cache if pccard_validate_cis fails. Furthermore, do not remove the fake CIS in destroy_cis_cache() but do so explicitely in the code paths where it makes sense. Tested-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/pcmcia/cistpl.c')
-rw-r--r--drivers/pcmcia/cistpl.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
index 25b1cd219e37..41ec7729eddc 100644
--- a/drivers/pcmcia/cistpl.c
+++ b/drivers/pcmcia/cistpl.c
@@ -319,22 +319,23 @@ remove_cis_cache(struct pcmcia_socket *s, int attr, u_int addr, u_int len)
319 } 319 }
320} 320}
321 321
322/**
323 * destroy_cis_cache() - destroy the CIS cache
324 * @s: pcmcia_socket for which CIS cache shall be destroyed
325 *
326 * This destroys the CIS cache but keeps any fake CIS alive.
327 */
328
322void destroy_cis_cache(struct pcmcia_socket *s) 329void destroy_cis_cache(struct pcmcia_socket *s)
323{ 330{
324 struct list_head *l, *n; 331 struct list_head *l, *n;
332 struct cis_cache_entry *cis;
325 333
326 list_for_each_safe(l, n, &s->cis_cache) { 334 list_for_each_safe(l, n, &s->cis_cache) {
327 struct cis_cache_entry *cis = list_entry(l, struct cis_cache_entry, node); 335 cis = list_entry(l, struct cis_cache_entry, node);
328
329 list_del(&cis->node); 336 list_del(&cis->node);
330 kfree(cis); 337 kfree(cis);
331 } 338 }
332
333 /*
334 * If there was a fake CIS, destroy that as well.
335 */
336 kfree(s->fake_cis);
337 s->fake_cis = NULL;
338} 339}
339EXPORT_SYMBOL(destroy_cis_cache); 340EXPORT_SYMBOL(destroy_cis_cache);
340 341
@@ -1596,6 +1597,9 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int *info)
1596 if (!s) 1597 if (!s)
1597 return -EINVAL; 1598 return -EINVAL;
1598 1599
1600 /* We do not want to validate the CIS cache... */
1601 destroy_cis_cache(s);
1602
1599 tuple = kmalloc(sizeof(*tuple), GFP_KERNEL); 1603 tuple = kmalloc(sizeof(*tuple), GFP_KERNEL);
1600 if (tuple == NULL) { 1604 if (tuple == NULL) {
1601 dev_printk(KERN_WARNING, &s->dev, "no memory to validate CIS\n"); 1605 dev_printk(KERN_WARNING, &s->dev, "no memory to validate CIS\n");
@@ -1647,6 +1651,10 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int *info)
1647 count = 0; 1651 count = 0;
1648 1652
1649done: 1653done:
1654 /* invalidate CIS cache on failure */
1655 if (!dev_ok || !ident_ok || !count)
1656 destroy_cis_cache(s);
1657
1650 if (info) 1658 if (info)
1651 *info = count; 1659 *info = count;
1652 kfree(tuple); 1660 kfree(tuple);