[PATCH 1/1] drivers/gpu/drm/i915: Fixed uninitialized variables (warnings).

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>From 1e77059e8f3158fd4844e3f6a5466a063d2f407e Mon Sep 17 00:00:00 2001
From: "Raphael S.Carvalho" <utroz@xxxxxxxxxxxxx>
Date: Mon, 14 May 2012 20:19:24 -0300
Subject: [PATCH 1/1]     drivers/gpu/drm/i915: Fixed uninitialized
 variables (warnings).
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

As you see, this modifications were really very important because if the remain variable receives a value lower or equals than 0 from the args->size variable, indeed, a bad behavior could ocurrs.

Let me explain:
The variable ret would never be initialized if the function doesn't enter inside of the loop. So that, the function will return a strange (undefined) value when it reaches the final.

If you've a better solution or if I commited a mistake in my changes, please talk me about. I'm sure I'm a newcomer, hehe.

I'm using the GCC: gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)

Warnings received during make operation:
utroz@utrozpc:~/linux$ make > make_output
    : In function ‘i915_gem_pread_ioctl’:
drivers/gpu/drm/i915/i915_gem.c:455:21: warning: ‘ret’ may be used uninitialized in this function [-Wuninitialized]
drivers/gpu/drm/i915/i915_gem.c:390:38: note: ‘ret’ was declared here
drivers/gpu/drm/i915/i915_gem.c: In function ‘i915_gem_pwrite_ioctl’:
drivers/gpu/drm/i915/i915_gem.c:871:21: warning: ‘ret’ may be used uninitialized in this function [-Wuninitialized]
drivers/gpu/drm/i915/i915_gem.c:797:38: note: ‘ret’ was declared here

Signed-off-by: Raphael S.Carvalho <rsc.utroz@xxxxxxxxx>
---
 drivers/gpu/drm/i915/i915_gem.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 0d1e4b7..b0a0004 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -392,6 +392,10 @@ i915_gem_shmem_pread_slow(struct drm_device *dev,
 
     user_data = (char __user *) (uintptr_t) args->data_ptr;
     remain = args->size;
+    if (remain <= 0) {
+        ret = -EINVAL;
+        goto final;
+    }
 
     obj_do_bit17_swizzling = i915_gem_object_needs_bit17_swizzle(obj);
 
@@ -451,7 +455,7 @@ out:
     /* Fixup: Kill any reinstated backing storage pages */
     if (obj->madv == __I915_MADV_PURGED)
         i915_gem_object_truncate(obj);
-
+final:
     return ret;
 }
 
@@ -799,6 +803,10 @@ i915_gem_shmem_pwrite_slow(struct drm_device *dev,
 
     user_data = (char __user *) (uintptr_t) args->data_ptr;
     remain = args->size;
+    if (remain <= 0) {
+        ret = -EINVAL;
+        goto final;
+    }
 
     obj_do_bit17_swizzling = i915_gem_object_needs_bit17_swizzle(obj);
 
@@ -867,7 +875,7 @@ out:
         i915_gem_clflush_object(obj);
         intel_gtt_chipset_flush();
     }
-
+final:
     return ret;
 }
 
--
1.7.5.4

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel

[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux