staging: vchiq_arm: handle error case of get_user_pages
authorStefan Wahren <stefan.wahren@i2se.com>
Mon, 31 Oct 2016 14:39:31 +0000 (14:39 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 7 Nov 2016 10:05:47 +0000 (11:05 +0100)
It's possible that get_user_pages() could fail. So evaluate its
return code and handle this error case properly.

This issue has been found by Cppcheck.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c

index 6ea8f1335b78644e570c2854cf0e1f86b5f8912c..90296c268a79f2c5fe3224b25872ce9ac58622fd 100644 (file)
@@ -1579,6 +1579,12 @@ dump_phys_mem(void *virt_addr, uint32_t num_bytes)
        prev_idx = -1;
        page = NULL;
 
+       if (rc < 0) {
+               vchiq_log_error(vchiq_arm_log_level,
+                               "Failed to get user pages: %d\n", rc);
+               goto out;
+       }
+
        while (offset < end_offset) {
 
                int page_offset = offset % PAGE_SIZE;
@@ -1602,6 +1608,8 @@ dump_phys_mem(void *virt_addr, uint32_t num_bytes)
 
                offset += 16;
        }
+
+out:
        if (page != NULL)
                kunmap(page);