diff --git a/fs/read_write.c b/fs/read_write.c
index 833bae068770..426ec5044f81 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -459,13 +459,16 @@ int rw_verify_area(int read_write, struct file *file, const loff_t *ppos, size_t
 	if (ppos) {
 		loff_t pos = *ppos;

-		if (unlikely(pos < 0)) {
-			if (!unsigned_offsets(file))
+		if (!unsigned_offsets(file))
+			return -EINVAL;
+		if (unsigned_offsets(file)) {
+			if (check_add_overflow ((uoff_t) pos, count,
+						&(uoff_t) {0}))
 				return -EINVAL;
-			if (count >= -pos) /* both values are in 0..LLONG_MAX */
-				return -EOVERFLOW;
-		} else if (unlikely((loff_t) (pos + count) < 0)) {
-			if (!unsigned_offsets(file))
+		} else {
+			if (unlikely(pos < 0))
+				return -EINVAL;
+			if (check_add_overflow (pos, count, &(loff_t) {0}))
 				return -EINVAL;
 		}
 	}
