aboutsummaryrefslogtreecommitdiffstats
path: root/fs/squashfs/cache.c
diff options
context:
space:
mode:
authorPhillip Lougher <phillip@squashfs.org.uk>2011-12-28 22:50:20 -0500
committerPhillip Lougher <phillip@squashfs.org.uk>2011-12-29 20:20:14 -0500
commite552a596687bf0e1802c744a7bb113afbd2bf4d4 (patch)
tree3080861e7587446872ed1886c2b2d031680a1b04 /fs/squashfs/cache.c
parent5f0a6e2d503896062f641639dacfe5055c2f593b (diff)
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>
Diffstat (limited to 'fs/squashfs/cache.c')
-rw-r--r--fs/squashfs/cache.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/fs/squashfs/cache.c b/fs/squashfs/cache.c
index f744be98cd5a..ea6e798e548b 100644
--- a/fs/squashfs/cache.c
+++ b/fs/squashfs/cache.c
@@ -332,17 +332,20 @@ int squashfs_read_metadata(struct super_block *sb, void *buffer,
332 u64 *block, int *offset, int length) 332 u64 *block, int *offset, int length)
333{ 333{
334 struct squashfs_sb_info *msblk = sb->s_fs_info; 334 struct squashfs_sb_info *msblk = sb->s_fs_info;
335 int bytes, copied = length; 335 int bytes, res = length;
336 struct squashfs_cache_entry *entry; 336 struct squashfs_cache_entry *entry;
337 337
338 TRACE("Entered squashfs_read_metadata [%llx:%x]\n", *block, *offset); 338 TRACE("Entered squashfs_read_metadata [%llx:%x]\n", *block, *offset);
339 339
340 while (length) { 340 while (length) {
341 entry = squashfs_cache_get(sb, msblk->block_cache, *block, 0); 341 entry = squashfs_cache_get(sb, msblk->block_cache, *block, 0);
342 if (entry->error) 342 if (entry->error) {
343 return entry->error; 343 res = entry->error;
344 else if (*offset >= entry->length) 344 goto error;
345 return -EIO; 345 } else if (*offset >= entry->length) {
346 res = -EIO;
347 goto error;
348 }
346 349
347 bytes = squashfs_copy_data(buffer, entry, *offset, length); 350 bytes = squashfs_copy_data(buffer, entry, *offset, length);
348 if (buffer) 351 if (buffer)
@@ -358,7 +361,11 @@ int squashfs_read_metadata(struct super_block *sb, void *buffer,
358 squashfs_cache_put(entry); 361 squashfs_cache_put(entry);
359 } 362 }
360 363
361 return copied; 364 return res;
365
366error:
367 squashfs_cache_put(entry);
368 return res;
362} 369}
363 370
364 371