gpu/drm/radeon/radeon_irq.c: move a dereference below a NULL test
authorDarren Jenkins <darrenrjenkins@gmail.com>
Wed, 30 Dec 2009 01:16:35 +0000 (12:16 +1100)
committerDave Airlie <airlied@redhat.com>
Thu, 7 Jan 2010 03:56:32 +0000 (13:56 +1000)
If a NULL value is possible, the dereference should only occur after the
NULL test.

Coverity CID: 13338

Signed-off-by: Darren Jenkins <darrenrjenkins@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/radeon/radeon_irq.c

index b79ecc4a7cc4da8975e4fe0fb9677d6700870085..2f349a300195992c9450c9ddd1d6e091eed23ef8 100644 (file)
@@ -289,16 +289,16 @@ int radeon_irq_emit(struct drm_device *dev, void *data, struct drm_file *file_pr
        drm_radeon_irq_emit_t *emit = data;
        int result;
 
-       if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
-               return -EINVAL;
-
-       LOCK_TEST_WITH_RETURN(dev, file_priv);
-
        if (!dev_priv) {
                DRM_ERROR("called with no initialization\n");
                return -EINVAL;
        }
 
+       if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
+               return -EINVAL;
+
+       LOCK_TEST_WITH_RETURN(dev, file_priv);
+
        result = radeon_emit_irq(dev);
 
        if (DRM_COPY_TO_USER(emit->irq_seq, &result, sizeof(int))) {