From: Dan Carpenter Date: Wed, 8 Sep 2010 19:44:47 +0000 (+0200) Subject: i915: snprintf returns large values X-Git-Tag: v2.6.37-rc1~77^2~31^2~171 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f4433a8d5d3076775bdd1a996a47db7beb468ac0;p=profile%2Fivi%2Fkernel-adaptation-intel-automotive.git i915: snprintf returns large values snprintf() returns the number of bytes which would have been used if there was enough space. It can be larger than the size of the buffer. Obviously in this case the buffer is large enough but everyone just copy and pastes this code so it's better to limit it and set a good example. Signed-off-by: Dan Carpenter Signed-off-by: Chris Wilson --- diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 2f3e017..7700ccf 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -886,6 +886,9 @@ i915_wedged_read(struct file *filp, "wedged : %d\n", atomic_read(&dev_priv->mm.wedged)); + if (len > sizeof (buf)) + len = sizeof (buf); + return simple_read_from_buffer(ubuf, max, ppos, buf, len); }