drm: check return values in drm_version
authorAndres Salomon <dilinger@collabora.co.uk>
Tue, 17 Nov 2009 22:41:25 +0000 (14:41 -0800)
committerDave Airlie <airlied@redhat.com>
Wed, 18 Nov 2009 00:02:50 +0000 (10:02 +1000)
In drm_version, actually check the results from function calls so that
we're not potentially passing garbage back to userspace.

Signed-off-by: Andres Salomon <dilinger@collabora.co.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/drm_drv.c

index ec0e3ae..5bd3f94 100644 (file)
@@ -403,15 +403,21 @@ static int drm_version(struct drm_device *dev, void *data,
                       struct drm_file *file_priv)
 {
        struct drm_version *version = data;
+       int err;
 
        version->version_major = dev->driver->major;
        version->version_minor = dev->driver->minor;
        version->version_patchlevel = dev->driver->patchlevel;
-       drm_copy_field(version->name, &version->name_len, dev->driver->name);
-       drm_copy_field(version->date, &version->date_len, dev->driver->date);
-       drm_copy_field(version->desc, &version->desc_len, dev->driver->desc);
-
-       return 0;
+       err = drm_copy_field(version->name, &version->name_len,
+                       dev->driver->name);
+       if (!err)
+               err = drm_copy_field(version->date, &version->date_len,
+                               dev->driver->date);
+       if (!err)
+               err = drm_copy_field(version->desc, &version->desc_len,
+                               dev->driver->desc);
+
+       return err;
 }
 
 /**