]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - net/rds/rdma.c
net: fix rds_iovec page count overflow
[karo-tx-linux.git] / net / rds / rdma.c
index 1a41debca1ce6aa6d57d7c6fda1e135c7babdf30..0df02c8a853362cbfddfa88f4d3eae3f17b81f62 100644 (file)
@@ -502,6 +502,13 @@ static int rds_rdma_pages(struct rds_rdma_args *args)
                        return -EINVAL;
 
                tot_pages += nr_pages;
+
+               /*
+                * nr_pages for one entry is limited to (UINT_MAX>>PAGE_SHIFT)+1,
+                * so tot_pages cannot overflow without first going negative.
+                */
+               if ((int)tot_pages < 0)
+                       return -EINVAL;
        }
 
        return tot_pages;