]> git.karo-electronics.de Git - karo-tx-linux.git/commit
mm: iov_iter: have iov_iter_advance() decrement nr_segs appropriately
authorJeff Layton <jlayton@redhat.com>
Wed, 5 Oct 2011 00:43:03 +0000 (11:43 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 5 Oct 2011 07:50:42 +0000 (18:50 +1100)
commitf2196c0db2904c67977d45dc6f63e74d75a332cb
treecea27a85eaf5858b7f8589b192b441b2d291c809
parent399c99c37594da946a65b2fec12a7bb3e174225f
mm: iov_iter: have iov_iter_advance() decrement nr_segs appropriately

Currently, when you call iov_iter_advance, then the pointer to the iovec
array can be incremented, but it does not decrement the nr_segs value in
the iov_iter struct.  The result is a iov_iter struct with a nr_segs value
that goes beyond the end of the array.

While I'm not aware of anything that's specifically broken by this, it
seems odd and a bit dangerous not to decrement that value.  If someone
were to trust the nr_segs value to be correct, then they could end up
walking off the end of the array.

Changing this might also provide some micro-optimization when dealing with
the last iovec in an array.  Many of the other routines that deal with
iov_iter have optimized codepaths when nr_segs == 1.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Cc: Nick Piggin <npiggin@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/filemap.c