Skip to content

Commit

Permalink
caif: handle snprintf() return
Browse files Browse the repository at this point in the history
snprintf() returns the number of bytes that would have been written.  It
can be larger than the size of the buffer.  The current code won't
overflow, but people cut and paste this stuff so lets do it right and
also make the static checkers happy.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Dan Carpenter authored and David S. Miller committed Jul 27, 2010
1 parent 652c671 commit 7b7b0b9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/net/caif/caif_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ static ssize_t dbgfs_state(struct file *file, char __user *user_buf,
len += snprintf((buf + len), (DEBUGFS_BUF_SIZE - len),
"Next RX len: %d\n", cfspi->rx_npck_len);

if (len > DEBUGFS_BUF_SIZE)
len = DEBUGFS_BUF_SIZE;

size = simple_read_from_buffer(user_buf, count, ppos, buf, len);
kfree(buf);

Expand Down

0 comments on commit 7b7b0b9

Please sign in to comment.