aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c4
-rw-r--r--drivers/pcmcia/cistpl.c43
-rw-r--r--drivers/pcmcia/pcmcia_resource.c2
-rw-r--r--drivers/pcmcia/rsrc_nonstatic.c32
-rw-r--r--include/pcmcia/cs.h2
5 files changed, 50 insertions, 33 deletions
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index 267cbe0afd16..918b4a3eca57 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -491,7 +491,7 @@ static int mhz_mfc_config(struct pcmcia_device *link)
491 491
492 cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); 492 cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL);
493 if (!cfg_mem) 493 if (!cfg_mem)
494 return CS_OUT_OF_RESOURCE; 494 return -ENOMEM;
495 495
496 link->conf.Attributes |= CONF_ENABLE_SPKR; 496 link->conf.Attributes |= CONF_ENABLE_SPKR;
497 link->conf.Status = CCSR_AUDIO_ENA; 497 link->conf.Status = CCSR_AUDIO_ENA;
@@ -690,7 +690,7 @@ static int smc_setup(struct pcmcia_device *link)
690 690
691 cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); 691 cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL);
692 if (!cfg_mem) 692 if (!cfg_mem)
693 return CS_OUT_OF_RESOURCE; 693 return -ENOMEM;
694 694
695 tuple = &cfg_mem->tuple; 695 tuple = &cfg_mem->tuple;
696 parse = &cfg_mem->parse; 696 parse = &cfg_mem->parse;
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
index 1a513d9a8612..8d37768d0b46 100644
--- a/drivers/pcmcia/cistpl.c
+++ b/drivers/pcmcia/cistpl.c
@@ -352,7 +352,9 @@ int verify_cis_cache(struct pcmcia_socket *s)
352 352
353 buf = kmalloc(256, GFP_KERNEL); 353 buf = kmalloc(256, GFP_KERNEL);
354 if (buf == NULL) 354 if (buf == NULL)
355 return -1; 355 dev_printk(KERN_WARNING, &s->dev,
356 "no memory for verifying CIS\n");
357 return -ENOMEM;
356 list_for_each_entry(cis, &s->cis_cache, node) { 358 list_for_each_entry(cis, &s->cis_cache, node) {
357 int len = cis->len; 359 int len = cis->len;
358 360
@@ -384,15 +386,19 @@ int verify_cis_cache(struct pcmcia_socket *s)
384int pcmcia_replace_cis(struct pcmcia_socket *s, 386int pcmcia_replace_cis(struct pcmcia_socket *s,
385 const u8 *data, const size_t len) 387 const u8 *data, const size_t len)
386{ 388{
387 if (len > CISTPL_MAX_CIS_SIZE) 389 if (len > CISTPL_MAX_CIS_SIZE) {
388 return CS_BAD_SIZE; 390 dev_printk(KERN_WARNING, &s->dev, "replacement CIS too big\n");
389 kfree(s->fake_cis); 391 return -EINVAL;
390 s->fake_cis = kmalloc(len, GFP_KERNEL); 392 }
391 if (s->fake_cis == NULL) 393 kfree(s->fake_cis);
392 return CS_OUT_OF_RESOURCE; 394 s->fake_cis = kmalloc(len, GFP_KERNEL);
393 s->fake_cis_len = len; 395 if (s->fake_cis == NULL) {
394 memcpy(s->fake_cis, data, len); 396 dev_printk(KERN_WARNING, &s->dev, "no memory to replace CIS\n");
395 return 0; 397 return -ENOMEM;
398 }
399 s->fake_cis_len = len;
400 memcpy(s->fake_cis, data, len);
401 return 0;
396} 402}
397EXPORT_SYMBOL(pcmcia_replace_cis); 403EXPORT_SYMBOL(pcmcia_replace_cis);
398 404
@@ -1411,8 +1417,10 @@ int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t
1411 int ret; 1417 int ret;
1412 1418
1413 buf = kmalloc(256, GFP_KERNEL); 1419 buf = kmalloc(256, GFP_KERNEL);
1414 if (buf == NULL) 1420 if (buf == NULL) {
1415 return CS_OUT_OF_RESOURCE; 1421 dev_printk(KERN_WARNING, &s->dev, "no memory to read tuple\n");
1422 return -ENOMEM;
1423 }
1416 tuple.DesiredTuple = code; 1424 tuple.DesiredTuple = code;
1417 tuple.Attributes = TUPLE_RETURN_COMMON; 1425 tuple.Attributes = TUPLE_RETURN_COMMON;
1418 ret = pccard_get_first_tuple(s, function, &tuple); 1426 ret = pccard_get_first_tuple(s, function, &tuple);
@@ -1452,12 +1460,15 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, unsigned
1452 return CS_BAD_HANDLE; 1460 return CS_BAD_HANDLE;
1453 1461
1454 tuple = kmalloc(sizeof(*tuple), GFP_KERNEL); 1462 tuple = kmalloc(sizeof(*tuple), GFP_KERNEL);
1455 if (tuple == NULL) 1463 if (tuple == NULL) {
1456 return CS_OUT_OF_RESOURCE; 1464 dev_printk(KERN_WARNING, &s->dev, "no memory to validate CIS\n");
1465 return -ENOMEM;
1466 }
1457 p = kmalloc(sizeof(*p), GFP_KERNEL); 1467 p = kmalloc(sizeof(*p), GFP_KERNEL);
1458 if (p == NULL) { 1468 if (p == NULL) {
1459 kfree(tuple); 1469 kfree(tuple);
1460 return CS_OUT_OF_RESOURCE; 1470 dev_printk(KERN_WARNING, &s->dev, "no memory to validate CIS\n");
1471 return -ENOMEM;
1461 } 1472 }
1462 1473
1463 count = reserved = 0; 1474 count = reserved = 0;
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index 48e168e8165b..69d87a7e0766 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -780,7 +780,7 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h
780 for (w = 0; w < MAX_WIN; w++) 780 for (w = 0; w < MAX_WIN; w++)
781 if (!(s->state & SOCKET_WIN_REQ(w))) break; 781 if (!(s->state & SOCKET_WIN_REQ(w))) break;
782 if (w == MAX_WIN) 782 if (w == MAX_WIN)
783 return CS_OUT_OF_RESOURCE; 783 return CS_IN_USE;
784 784
785 win = &s->win[w]; 785 win = &s->win[w];
786 win->magic = WINDOW_MAGIC; 786 win->magic = WINDOW_MAGIC;
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index 9d04fb214ec2..0e4141bac7b1 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -122,19 +122,22 @@ static void free_region(struct resource *res)
122 122
123static int add_interval(struct resource_map *map, u_long base, u_long num) 123static int add_interval(struct resource_map *map, u_long base, u_long num)
124{ 124{
125 struct resource_map *p, *q; 125 struct resource_map *p, *q;
126 126
127 for (p = map; ; p = p->next) { 127 for (p = map; ; p = p->next) {
128 if ((p != map) && (p->base+p->num-1 >= base)) 128 if ((p != map) && (p->base+p->num-1 >= base))
129 return -1; 129 return -1;
130 if ((p->next == map) || (p->next->base > base+num-1)) 130 if ((p->next == map) || (p->next->base > base+num-1))
131 break; 131 break;
132 } 132 }
133 q = kmalloc(sizeof(struct resource_map), GFP_KERNEL); 133 q = kmalloc(sizeof(struct resource_map), GFP_KERNEL);
134 if (!q) return CS_OUT_OF_RESOURCE; 134 if (!q) {
135 q->base = base; q->num = num; 135 printk(KERN_WARNING "out of memory to update resources\n");
136 q->next = p->next; p->next = q; 136 return -ENOMEM;
137 return 0; 137 }
138 q->base = base; q->num = num;
139 q->next = p->next; p->next = q;
140 return 0;
138} 141}
139 142
140/*====================================================================*/ 143/*====================================================================*/
@@ -166,7 +169,10 @@ static int sub_interval(struct resource_map *map, u_long base, u_long num)
166 } else { 169 } else {
167 /* Split the block into two pieces */ 170 /* Split the block into two pieces */
168 p = kmalloc(sizeof(struct resource_map), GFP_KERNEL); 171 p = kmalloc(sizeof(struct resource_map), GFP_KERNEL);
169 if (!p) return CS_OUT_OF_RESOURCE; 172 if (!p) {
173 printk(KERN_WARNING "out of memory to update resources\n");
174 return -ENOMEM;
175 }
170 p->base = base+num; 176 p->base = base+num;
171 p->num = q->base+q->num - p->base; 177 p->num = q->base+q->num - p->base;
172 q->num = base - q->base; 178 q->num = base - q->base;
diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h
index 695baf6cf1fd..9e6916c1fa81 100644
--- a/include/pcmcia/cs.h
+++ b/include/pcmcia/cs.h
@@ -316,7 +316,7 @@ typedef struct error_info_t {
316#define CS_CONFIGURATION_LOCKED 0x1d 316#define CS_CONFIGURATION_LOCKED 0x1d
317#define CS_IN_USE 0x1e 317#define CS_IN_USE 0x1e
318#define CS_NO_MORE_ITEMS 0x1f 318#define CS_NO_MORE_ITEMS 0x1f
319#define CS_OUT_OF_RESOURCE 0x20 319#define CS_OUT_OF_RESOURCE -ENOMEM
320#define CS_BAD_HANDLE 0x21 320#define CS_BAD_HANDLE 0x21
321 321
322#define CS_BAD_TUPLE 0x40 322#define CS_BAD_TUPLE 0x40