Skip to content

Commit

Permalink
i915: snprintf returns large values
Browse files Browse the repository at this point in the history
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 <error27@gmail.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
  • Loading branch information
Dan Carpenter authored and Chris Wilson committed Sep 8, 2010
1 parent 1996675 commit f4433a8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/gpu/drm/i915/i915_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit f4433a8

Please sign in to comment.