diff options
Diffstat (limited to 'drivers/block/nvme-core.c')
-rw-r--r-- | drivers/block/nvme-core.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c index 8efdfaa44a59..437637551d1e 100644 --- a/drivers/block/nvme-core.c +++ b/drivers/block/nvme-core.c | |||
@@ -1206,7 +1206,7 @@ struct nvme_iod *nvme_map_user_pages(struct nvme_dev *dev, int write, | |||
1206 | 1206 | ||
1207 | if (addr & 3) | 1207 | if (addr & 3) |
1208 | return ERR_PTR(-EINVAL); | 1208 | return ERR_PTR(-EINVAL); |
1209 | if (!length) | 1209 | if (!length || length > INT_MAX - PAGE_SIZE) |
1210 | return ERR_PTR(-EINVAL); | 1210 | return ERR_PTR(-EINVAL); |
1211 | 1211 | ||
1212 | offset = offset_in_page(addr); | 1212 | offset = offset_in_page(addr); |
@@ -1227,7 +1227,8 @@ struct nvme_iod *nvme_map_user_pages(struct nvme_dev *dev, int write, | |||
1227 | sg_init_table(sg, count); | 1227 | sg_init_table(sg, count); |
1228 | for (i = 0; i < count; i++) { | 1228 | for (i = 0; i < count; i++) { |
1229 | sg_set_page(&sg[i], pages[i], | 1229 | sg_set_page(&sg[i], pages[i], |
1230 | min_t(int, length, PAGE_SIZE - offset), offset); | 1230 | min_t(unsigned, length, PAGE_SIZE - offset), |
1231 | offset); | ||
1231 | length -= (PAGE_SIZE - offset); | 1232 | length -= (PAGE_SIZE - offset); |
1232 | offset = 0; | 1233 | offset = 0; |
1233 | } | 1234 | } |