diff --git a/linux/agpsupport.c b/linux/agpsupport.c index 6dde31da..c2c1dbce 100644 --- a/linux/agpsupport.c +++ b/linux/agpsupport.c @@ -166,6 +166,8 @@ int drm_agp_alloc(struct inode *inode, struct file *filp, unsigned int cmd, -EFAULT); if (!(entry = drm_alloc(sizeof(*entry), DRM_MEM_AGPLISTS))) return -ENOMEM; + + memset(entry, 0, sizeof(*entry)); pages = (request.size + PAGE_SIZE - 1) / PAGE_SIZE; type = (u32) request.type; @@ -181,8 +183,11 @@ int drm_agp_alloc(struct inode *inode, struct file *filp, unsigned int cmd, entry->pages = pages; entry->prev = NULL; entry->next = dev->agp->memory; + printk("dev->agp->memory : %p\n", dev->agp->memory); + printk("entry : %p\n", entry); if (dev->agp->memory) dev->agp->memory->prev = entry; dev->agp->memory = entry; + printk("dev->agp->memory : %p\n", dev->agp->memory); request.handle = entry->handle; request.physical = memory->physical; @@ -263,9 +268,15 @@ int drm_agp_free(struct inode *inode, struct file *filp, unsigned int cmd, -EFAULT); if (!(entry = drm_agp_lookup_entry(dev, request.handle))) return -EINVAL; +#if 0 if (entry->bound) drm_unbind_agp(entry->memory); - entry->prev->next = entry->next; - entry->next->prev = entry->prev; +#endif + if(entry->prev) entry->prev->next = entry->next; + if(entry->next) entry->next->prev = entry->prev; + if((entry->next == NULL) && + (entry->prev == NULL)) { + dev->agp->memory = NULL; + } drm_free_agp(entry->memory, entry->pages); drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); return 0;