drm/radeon: check for allocation failure in radeon_ring_backup()
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 20 Jul 2012 11:17:00 +0000 (14:17 +0300)
committerDave Airlie <airlied@redhat.com>
Wed, 25 Jul 2012 04:12:17 +0000 (14:12 +1000)
Static checkers complain if this we don't check for allocation failure.
Also we can use the new kmalloc_array() function here as a cleanup.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/radeon/radeon_ring.c

index f2fc25d..ec79b37 100644 (file)
@@ -594,7 +594,11 @@ unsigned radeon_ring_backup(struct radeon_device *rdev, struct radeon_ring *ring
        }
 
        /* and then save the content of the ring */
-       *data = kmalloc(size * 4, GFP_KERNEL);
+       *data = kmalloc_array(size, sizeof(uint32_t), GFP_KERNEL);
+       if (!*data) {
+               mutex_unlock(&rdev->ring_lock);
+               return 0;
+       }
        for (i = 0; i < size; ++i) {
                (*data)[i] = ring->ring[ptr++];
                ptr &= ring->ptr_mask;