Skip to content

Commit

Permalink
vfs: in iomap seek_{hole,data}, return -ENXIO for negative offsets
Browse files Browse the repository at this point in the history
In the iomap implementations of SEEK_HOLE and SEEK_DATA, make sure we
return -ENXIO for negative offsets.

Inspired-by: Mateusz S <[email protected]>
Signed-off-by: Darrick J. Wong <[email protected]>
  • Loading branch information
djwong committed Jul 13, 2017
1 parent 0891f99 commit d6ab17f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fs/iomap.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,8 +610,8 @@ iomap_seek_hole(struct inode *inode, loff_t offset, const struct iomap_ops *ops)
loff_t length = size - offset;
loff_t ret;

/* Nothing to be found beyond the end of the file. */
if (offset >= size)
/* Nothing to be found before or beyond the end of the file. */
if (offset < 0 || offset >= size)
return -ENXIO;

while (length > 0) {
Expand Down Expand Up @@ -656,8 +656,8 @@ iomap_seek_data(struct inode *inode, loff_t offset, const struct iomap_ops *ops)
loff_t length = size - offset;
loff_t ret;

/* Nothing to be found beyond the end of the file. */
if (offset >= size)
/* Nothing to be found before or beyond the end of the file. */
if (offset < 0 || offset >= size)
return -ENXIO;

while (length > 0) {
Expand Down

0 comments on commit d6ab17f

Please sign in to comment.