mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 12:11:40 +00:00
Squashfs: add missing block release on error condition
squashfs_read_metadata forgets to release the cache block if an error has occurred. Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
This commit is contained in:
parent
5f0a6e2d50
commit
e552a59668
@ -332,17 +332,20 @@ int squashfs_read_metadata(struct super_block *sb, void *buffer,
|
|||||||
u64 *block, int *offset, int length)
|
u64 *block, int *offset, int length)
|
||||||
{
|
{
|
||||||
struct squashfs_sb_info *msblk = sb->s_fs_info;
|
struct squashfs_sb_info *msblk = sb->s_fs_info;
|
||||||
int bytes, copied = length;
|
int bytes, res = length;
|
||||||
struct squashfs_cache_entry *entry;
|
struct squashfs_cache_entry *entry;
|
||||||
|
|
||||||
TRACE("Entered squashfs_read_metadata [%llx:%x]\n", *block, *offset);
|
TRACE("Entered squashfs_read_metadata [%llx:%x]\n", *block, *offset);
|
||||||
|
|
||||||
while (length) {
|
while (length) {
|
||||||
entry = squashfs_cache_get(sb, msblk->block_cache, *block, 0);
|
entry = squashfs_cache_get(sb, msblk->block_cache, *block, 0);
|
||||||
if (entry->error)
|
if (entry->error) {
|
||||||
return entry->error;
|
res = entry->error;
|
||||||
else if (*offset >= entry->length)
|
goto error;
|
||||||
return -EIO;
|
} else if (*offset >= entry->length) {
|
||||||
|
res = -EIO;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
bytes = squashfs_copy_data(buffer, entry, *offset, length);
|
bytes = squashfs_copy_data(buffer, entry, *offset, length);
|
||||||
if (buffer)
|
if (buffer)
|
||||||
@ -358,7 +361,11 @@ int squashfs_read_metadata(struct super_block *sb, void *buffer,
|
|||||||
squashfs_cache_put(entry);
|
squashfs_cache_put(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
return copied;
|
return res;
|
||||||
|
|
||||||
|
error:
|
||||||
|
squashfs_cache_put(entry);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user