summaryrefslogtreecommitdiff
path: root/sys/dev/pci/drm/savage_bci.c
diff options
context:
space:
mode:
authorOwain Ainsworth <oga@cvs.openbsd.org>2008-07-29 19:44:14 +0000
committerOwain Ainsworth <oga@cvs.openbsd.org>2008-07-29 19:44:14 +0000
commitb8dc197adc12e93026b921e8cb874f859680c8e9 (patch)
treeb2b0322ceddd22b62a28af8ba9ce7a5245756a87 /sys/dev/pci/drm/savage_bci.c
parenta34164765a74068498e9c1b4e4a5322fec0068f7 (diff)
Switch all instances of malloc/free in the DRM to drm_alloc, drm_free
and drm_calloc. With the recent change to check overflow in drm_calloc, this means that all allocations that require multiplication are now checked. Also use drm_calloc() when zeroing is needed and drop the bzero/memset afterwards. Finally, make drm_free() check for NULL, so we don't need to do so every time. ok miod@, deraadt@
Diffstat (limited to 'sys/dev/pci/drm/savage_bci.c')
-rw-r--r--sys/dev/pci/drm/savage_bci.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/sys/dev/pci/drm/savage_bci.c b/sys/dev/pci/drm/savage_bci.c
index 4b8a89fea64..c4fe2819500 100644
--- a/sys/dev/pci/drm/savage_bci.c
+++ b/sys/dev/pci/drm/savage_bci.c
@@ -298,8 +298,8 @@ static int savage_dma_init(drm_savage_private_t *dev_priv)
dev_priv->nr_dma_pages = dev_priv->cmd_dma->size /
(SAVAGE_DMA_PAGE_SIZE*4);
- dev_priv->dma_pages = drm_alloc(sizeof(drm_savage_dma_page_t) *
- dev_priv->nr_dma_pages, DRM_MEM_DRIVER);
+ dev_priv->dma_pages = drm_calloc(sizeof(drm_savage_dma_page_t),
+ dev_priv->nr_dma_pages, DRM_MEM_DRIVER);
if (dev_priv->dma_pages == NULL)
return -ENOMEM;
@@ -539,11 +539,10 @@ int savage_driver_load(struct drm_device *dev, unsigned long chipset)
{
drm_savage_private_t *dev_priv;
- dev_priv = drm_alloc(sizeof(drm_savage_private_t), DRM_MEM_DRIVER);
+ dev_priv = drm_calloc(1, sizeof(drm_savage_private_t), DRM_MEM_DRIVER);
if (dev_priv == NULL)
return -ENOMEM;
- memset(dev_priv, 0, sizeof(drm_savage_private_t));
dev->dev_private = (void *)dev_priv;
dev_priv->chipset = (enum savage_family)chipset;
@@ -804,7 +803,7 @@ static int savage_do_init_bci(struct drm_device *dev, drm_savage_init_t *init)
dev_priv->fake_dma.size = SAVAGE_FAKE_DMA_SIZE;
dev_priv->fake_dma.type = _DRM_SHM;
dev_priv->fake_dma.handle = drm_alloc(SAVAGE_FAKE_DMA_SIZE,
- DRM_MEM_DRIVER);
+ DRM_MEM_DRIVER);
if (!dev_priv->fake_dma.handle) {
DRM_ERROR("could not allocate faked DMA buffer!\n");
savage_do_cleanup_bci(dev);