Skip to contentSkip to conversation

fs: generic_file_llseek_size() should recognize invalid whence values

PATCH New Richard Yao 1 participant 1 message Jun 16, 2013 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs: generic_file_llseek_size() should recognize invalid whence values

generic_file_llseek_size() handles whence values in a switch statement, but it lacks cases for both SEEK_SET and invalid values. This causes it to treat all invalid whence values as SEEK_SET, which is wrong.

We fix that by adding a case for SEEK_SET and a default case.

---
 fs/read_write.c | 3 +++
 1 file changed, 3 insertions(+)
fs/read_write.c +3 -0
index 0343000..54b8808 100644
@@ -81,6 +81,7 @@ generic_file_llseek_size(struct file *file, loff_t offset, int whence,
 	switch (whence) {
 	case SEEK_END:
 		offset += eof;
+	case SEEK_SET:
 		break;
 	case SEEK_CUR:
 		/*
@@ -118,6 +119,8 @@ generic_file_llseek_size(struct file *file, loff_t offset, int whence,
 			return -ENXIO;
 		offset = eof;
 		break;
+	default:
+		return -EINVAL;
 	}
 
 	return lseek_execute(file, inode, offset, maxsize);
Signature · 1 line
1.8.1.5