Checking inode attributes after a loop that modifies the file pointer the inode has been derived from confuses some static analyzers. Hence swap the loop and the inode attribute check. Signed-off-by: Bart Van Assche --- drivers/block/loop.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 36deb08ee463..4315c36d4042 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -506,6 +506,9 @@ static int loop_validate_file(struct file *file, struct block_device *bdev) struct inode *inode = file->f_mapping->host; struct file *f = file; + if (!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode)) + return -EINVAL; + /* Avoid recursion */ while (is_loop_device(f)) { struct loop_device *l; @@ -522,8 +525,6 @@ static int loop_validate_file(struct file *file, struct block_device *bdev) rmb(); f = l->lo_backing_file; } - if (!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode)) - return -EINVAL; return 0; }