From: Jens Axboe Date: Fri, 11 Aug 2006 20:29:11 +0000 (+0200) Subject: Fix missing ret assignment in __bio_map_user() error path X-Git-Tag: v2.6.16.28-rc1~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dec0370af02c080b1a9c240058a9887fc53a5f08;p=thirdparty%2Fkernel%2Fstable.git Fix missing ret assignment in __bio_map_user() error path If get_user_pages() returns less pages than what we asked for, we jump to out_unmap which will return ERR_PTR(ret). But ret can contain a positive number just smaller than local_nr_pages, so be sure to set it to -EFAULT always. Problem found and diagnosed by Damien Le Moal Signed-off-by: Jens Axboe Signed-off-by: Adrian Bunk --- diff --git a/fs/bio.c b/fs/bio.c index 1f3bb501c262b..7215911464e4a 100644 --- a/fs/bio.c +++ b/fs/bio.c @@ -655,9 +655,10 @@ static struct bio *__bio_map_user_iov(request_queue_t *q, write_to_vm, 0, &pages[cur_page], NULL); up_read(¤t->mm->mmap_sem); - if (ret < local_nr_pages) + if (ret < local_nr_pages) { + ret = -EFAULT; goto out_unmap; - + } offset = uaddr & ~PAGE_MASK; for (j = cur_page; j < page_limit; j++) {