]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
ceph: handle partial result from get_user_pages
authorHenry C Chang <henry_c_chang@tcloudcomputing.com>
Fri, 17 Dec 2010 17:55:59 +0000 (09:55 -0800)
committerSage Weil <sage@newdream.net>
Fri, 17 Dec 2010 17:55:59 +0000 (09:55 -0800)
The get_user_pages() helper can return fewer than the requested pages.
Error out in that case, and clean up the partial result.

Signed-off-by: Henry C Chang <henry_c_chang@tcloudcomputing.com>
Signed-off-by: Sage Weil <sage@newdream.net>
net/ceph/pagevec.c

index 01947a5d03b71bc02ddd7a677454ab6be30e9d04..1a040e64c69f23545f98e282bae934b3ed33baa9 100644 (file)
@@ -26,12 +26,12 @@ struct page **ceph_get_direct_page_vector(const char __user *data,
        rc = get_user_pages(current, current->mm, (unsigned long)data,
                            num_pages, write_page, 0, pages, NULL);
        up_read(&current->mm->mmap_sem);
-       if (rc < 0)
+       if (rc < num_pages)
                goto fail;
        return pages;
 
 fail:
-       kfree(pages);
+       ceph_put_page_vector(pages, rc > 0 ? rc : 0, false);
        return ERR_PTR(rc);
 }
 EXPORT_SYMBOL(ceph_get_direct_page_vector);