Skip to content

Commit

Permalink
Squashfs: add missing block release on error condition
Browse files Browse the repository at this point in the history
squashfs_read_metadata forgets to release the cache block if
an error has occurred.

Signed-off-by: Phillip Lougher <[email protected]>
  • Loading branch information
plougher committed Dec 30, 2011
1 parent 5f0a6e2 commit e552a59
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions fs/squashfs/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,17 +332,20 @@ int squashfs_read_metadata(struct super_block *sb, void *buffer,
u64 *block, int *offset, int length)
{
struct squashfs_sb_info *msblk = sb->s_fs_info;
int bytes, copied = length;
int bytes, res = length;
struct squashfs_cache_entry *entry;

TRACE("Entered squashfs_read_metadata [%llx:%x]\n", *block, *offset);

while (length) {
entry = squashfs_cache_get(sb, msblk->block_cache, *block, 0);
if (entry->error)
return entry->error;
else if (*offset >= entry->length)
return -EIO;
if (entry->error) {
res = entry->error;
goto error;
} else if (*offset >= entry->length) {
res = -EIO;
goto error;
}

bytes = squashfs_copy_data(buffer, entry, *offset, length);
if (buffer)
Expand All @@ -358,7 +361,11 @@ int squashfs_read_metadata(struct super_block *sb, void *buffer,
squashfs_cache_put(entry);
}

return copied;
return res;

error:
squashfs_cache_put(entry);
return res;
}


Expand Down

0 comments on commit e552a59

Please sign in to comment.