aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/cistpl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pcmcia/cistpl.c')
-rw-r--r--drivers/pcmcia/cistpl.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
index 65129b54eb09..11c473c865a5 100644
--- a/drivers/pcmcia/cistpl.c
+++ b/drivers/pcmcia/cistpl.c
@@ -265,13 +265,13 @@ EXPORT_SYMBOL(pcmcia_write_cis_mem);
265======================================================================*/ 265======================================================================*/
266 266
267static void read_cis_cache(struct pcmcia_socket *s, int attr, u_int addr, 267static void read_cis_cache(struct pcmcia_socket *s, int attr, u_int addr,
268 u_int len, void *ptr) 268 size_t len, void *ptr)
269{ 269{
270 struct cis_cache_entry *cis; 270 struct cis_cache_entry *cis;
271 int ret; 271 int ret;
272 272
273 if (s->fake_cis) { 273 if (s->fake_cis) {
274 if (s->fake_cis_len > addr+len) 274 if (s->fake_cis_len >= addr+len)
275 memcpy(ptr, s->fake_cis+addr, len); 275 memcpy(ptr, s->fake_cis+addr, len);
276 else 276 else
277 memset(ptr, 0xff, len); 277 memset(ptr, 0xff, len);
@@ -380,17 +380,17 @@ int verify_cis_cache(struct pcmcia_socket *s)
380 380
381======================================================================*/ 381======================================================================*/
382 382
383int pcmcia_replace_cis(struct pcmcia_socket *s, cisdump_t *cis) 383int pcmcia_replace_cis(struct pcmcia_socket *s,
384 const u8 *data, const size_t len)
384{ 385{
385 kfree(s->fake_cis); 386 if (len > CISTPL_MAX_CIS_SIZE)
386 s->fake_cis = NULL;
387 if (cis->Length > CISTPL_MAX_CIS_SIZE)
388 return CS_BAD_SIZE; 387 return CS_BAD_SIZE;
389 s->fake_cis = kmalloc(cis->Length, GFP_KERNEL); 388 kfree(s->fake_cis);
389 s->fake_cis = kmalloc(len, GFP_KERNEL);
390 if (s->fake_cis == NULL) 390 if (s->fake_cis == NULL)
391 return CS_OUT_OF_RESOURCE; 391 return CS_OUT_OF_RESOURCE;
392 s->fake_cis_len = cis->Length; 392 s->fake_cis_len = len;
393 memcpy(s->fake_cis, cis->Data, cis->Length); 393 memcpy(s->fake_cis, data, len);
394 return CS_SUCCESS; 394 return CS_SUCCESS;
395} 395}
396EXPORT_SYMBOL(pcmcia_replace_cis); 396EXPORT_SYMBOL(pcmcia_replace_cis);