fs/affs: release memory if affs_init_bitmap fails
Subsystems (2)
PATCH 1/1 fs/affs: release memory if affs_init_bitmap fails
In affs_init_bitmap, on error handling path we may release the allocated memory.
--- fs/affs/bitmap.c | 1 + 1 file changed, 1 insertion(+)
fs/affs/bitmap.c +1 -0
@@ -347,6 +347,7 @@ int affs_init_bitmap(struct super_block *sb, int *flags) out:affs_brelse (bh);affs_brelse (bmap_bh); +kfree (sbi->s_bitmap);return res; }
Signature · 1 line
2.17.1
Quoted 2 lines · Navid Emamdoost
In
affs_init_bitmap, on error handling path we may release the allocated memory.
Yes the memory should be released but not all paths that lead to the label 'out' are actually errors:
288 if (affs_checksum_block(sb, bh)) {
289 pr_warn("Bitmap %u invalid - mounting %s read only.\n",
290 bm->bm_key, sb->s_id);
291 *flags |= SB_RDONLY;
292 goto out;
293 }
ie. the return value 'res' is still 0, and the filesystem is mounted read-only.
Quoted 10 lines
Signed-off-by Navid Emamdoost <[email protected]>--- fs/affs/bitmap.c | 1 + 1 file changed, 1 insertion(+)fs/affs/bitmap.c +0
-0
fs/affs/bitmap.c int affs_init_bitmap(struct super_block *sb, int *flags) · line 350
Quoted 4 lines
fs/affs/bitmap.c +1
-0@@ -347,6 +347,7 @@ int affs_init_bitmap(struct super_block *sb, int *flags) out:affs_brelse (bh);affs_brelse (bmap_bh); +kfree (sbi->s_bitmap);
The sbi->s_bitmap would be freed but at umount time it will be freed again.
Quoted 7 lines
fs/affs/bitmap.c +0
-0return res; }Signature · 1 line
2.17.1
Al Viro
maintainerQuoted 6 lines · David Sterba
Quoted 2 lines · Navid Emamdoost
In
affs_init_bitmap, on error handling path we may release the allocated memory.Yes the memory should be released but not all paths that lead to the label 'out' are actually errors:
... and none of them should be freeing anything here, errors or no errors.
Quoted 2 lines
The
sbi->s_bitmapwould be freed but at umount time it will be freed again.
It actually would be freed by superblock destructor, be it on umount or on failed fill_super.