Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs

Pull misc udf, ext2, ext3, and isofs fixes from Jan Kara:
"Assorted, mostly trivial, fixes for udf, ext2, ext3, and isofs. I'm
on vacation and scarcely checking email since we are expecting baby
any day now but these fixes should be safe to go in and I don't want
to delay them unnecessarily."

* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
udf: avoid info leak on export
isofs: avoid info leak on export
udf: Improve table length check to avoid possible overflow
ext3: Check return value of blkdev_issue_flush()
jbd: Check return value of blkdev_issue_flush()
udf: Do not decrement i_blocks when freeing indirect extent block
udf: Fix memory leak when mounting
ext2: cleanup the confused goto label
UDF: Remove unnecessary variable "offset" from udf_fill_inode
udf: stop using s_dirt
ext3: force ro mount if ext3_setup_super() fails
quota: fix checkpatch.pl warning by replacing <asm/uaccess.h> with <linux/uaccess.h>

+88 -82
+3 -3
fs/ext2/super.c
··· 771 771 err = -ENOMEM; 772 772 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); 773 773 if (!sbi) 774 - goto failed_unlock; 774 + goto failed; 775 775 776 776 sbi->s_blockgroup_lock = 777 777 kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL); 778 778 if (!sbi->s_blockgroup_lock) { 779 779 kfree(sbi); 780 - goto failed_unlock; 780 + goto failed; 781 781 } 782 782 sb->s_fs_info = sbi; 783 783 sbi->s_sb_block = sb_block; ··· 1130 1130 sb->s_fs_info = NULL; 1131 1131 kfree(sbi->s_blockgroup_lock); 1132 1132 kfree(sbi); 1133 - failed_unlock: 1133 + failed: 1134 1134 return ret; 1135 1135 } 1136 1136
+7 -2
fs/ext3/fsync.c
··· 92 92 * disk caches manually so that data really is on persistent 93 93 * storage 94 94 */ 95 - if (needs_barrier) 96 - blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL); 95 + if (needs_barrier) { 96 + int err; 97 + 98 + err = blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL); 99 + if (!ret) 100 + ret = err; 101 + } 97 102 out: 98 103 trace_ext3_sync_file_exit(inode, ret); 99 104 return ret;
+2 -1
fs/ext3/super.c
··· 2058 2058 goto failed_mount3; 2059 2059 } 2060 2060 2061 - ext3_setup_super (sb, es, sb->s_flags & MS_RDONLY); 2061 + if (ext3_setup_super(sb, es, sb->s_flags & MS_RDONLY)) 2062 + sb->s_flags |= MS_RDONLY; 2062 2063 2063 2064 EXT3_SB(sb)->s_mount_state |= EXT3_ORPHAN_FS; 2064 2065 ext3_orphan_cleanup(sb, es);
+1
fs/isofs/export.c
··· 134 134 len = 3; 135 135 fh32[0] = ei->i_iget5_block; 136 136 fh16[2] = (__u16)ei->i_iget5_offset; /* fh16 [sic] */ 137 + fh16[3] = 0; /* avoid leaking uninitialized data */ 137 138 fh32[2] = inode->i_generation; 138 139 if (parent) { 139 140 struct iso_inode_info *eparent;
+5 -2
fs/jbd/recovery.c
··· 265 265 if (!err) 266 266 err = err2; 267 267 /* Flush disk caches to get replayed data on the permanent storage */ 268 - if (journal->j_flags & JFS_BARRIER) 269 - blkdev_issue_flush(journal->j_fs_dev, GFP_KERNEL, NULL); 268 + if (journal->j_flags & JFS_BARRIER) { 269 + err2 = blkdev_issue_flush(journal->j_fs_dev, GFP_KERNEL, NULL); 270 + if (!err) 271 + err = err2; 272 + } 270 273 271 274 return err; 272 275 }
+1 -1
fs/quota/dquot.c
··· 78 78 #include <linux/quotaops.h> 79 79 #include "../internal.h" /* ugh */ 80 80 81 - #include <asm/uaccess.h> 81 + #include <linux/uaccess.h> 82 82 83 83 /* 84 84 * There are three quota SMP locks. dq_list_lock protects all lists with quotas
+1 -1
fs/quota/quota.c
··· 9 9 #include <linux/namei.h> 10 10 #include <linux/slab.h> 11 11 #include <asm/current.h> 12 - #include <asm/uaccess.h> 12 + #include <linux/uaccess.h> 13 13 #include <linux/kernel.h> 14 14 #include <linux/security.h> 15 15 #include <linux/syscalls.h>
-4
fs/udf/inode.c
··· 1247 1247 { 1248 1248 struct fileEntry *fe; 1249 1249 struct extendedFileEntry *efe; 1250 - int offset; 1251 1250 struct udf_sb_info *sbi = UDF_SB(inode->i_sb); 1252 1251 struct udf_inode_info *iinfo = UDF_I(inode); 1253 1252 unsigned int link_count; ··· 1358 1359 iinfo->i_lenEAttr = le32_to_cpu(fe->lengthExtendedAttr); 1359 1360 iinfo->i_lenAlloc = le32_to_cpu(fe->lengthAllocDescs); 1360 1361 iinfo->i_checkpoint = le32_to_cpu(fe->checkpoint); 1361 - offset = sizeof(struct fileEntry) + iinfo->i_lenEAttr; 1362 1362 } else { 1363 1363 inode->i_blocks = le64_to_cpu(efe->logicalBlocksRecorded) << 1364 1364 (inode->i_sb->s_blocksize_bits - 9); ··· 1379 1381 iinfo->i_lenEAttr = le32_to_cpu(efe->lengthExtendedAttr); 1380 1382 iinfo->i_lenAlloc = le32_to_cpu(efe->lengthAllocDescs); 1381 1383 iinfo->i_checkpoint = le32_to_cpu(efe->checkpoint); 1382 - offset = sizeof(struct extendedFileEntry) + 1383 - iinfo->i_lenEAttr; 1384 1384 } 1385 1385 1386 1386 switch (fe->icbTag.fileType) {
+1
fs/udf/namei.c
··· 1279 1279 *lenp = 3; 1280 1280 fid->udf.block = location.logicalBlockNum; 1281 1281 fid->udf.partref = location.partitionReferenceNum; 1282 + fid->udf.parent_partref = 0; 1282 1283 fid->udf.generation = inode->i_generation; 1283 1284 1284 1285 if (parent) {
+65 -65
fs/udf/super.c
··· 252 252 return 0; 253 253 } 254 254 255 + static void udf_sb_free_bitmap(struct udf_bitmap *bitmap) 256 + { 257 + int i; 258 + int nr_groups = bitmap->s_nr_groups; 259 + int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) * 260 + nr_groups); 261 + 262 + for (i = 0; i < nr_groups; i++) 263 + if (bitmap->s_block_bitmap[i]) 264 + brelse(bitmap->s_block_bitmap[i]); 265 + 266 + if (size <= PAGE_SIZE) 267 + kfree(bitmap); 268 + else 269 + vfree(bitmap); 270 + } 271 + 272 + static void udf_free_partition(struct udf_part_map *map) 273 + { 274 + int i; 275 + struct udf_meta_data *mdata; 276 + 277 + if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) 278 + iput(map->s_uspace.s_table); 279 + if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) 280 + iput(map->s_fspace.s_table); 281 + if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) 282 + udf_sb_free_bitmap(map->s_uspace.s_bitmap); 283 + if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) 284 + udf_sb_free_bitmap(map->s_fspace.s_bitmap); 285 + if (map->s_partition_type == UDF_SPARABLE_MAP15) 286 + for (i = 0; i < 4; i++) 287 + brelse(map->s_type_specific.s_sparing.s_spar_map[i]); 288 + else if (map->s_partition_type == UDF_METADATA_MAP25) { 289 + mdata = &map->s_type_specific.s_metadata; 290 + iput(mdata->s_metadata_fe); 291 + mdata->s_metadata_fe = NULL; 292 + 293 + iput(mdata->s_mirror_fe); 294 + mdata->s_mirror_fe = NULL; 295 + 296 + iput(mdata->s_bitmap_fe); 297 + mdata->s_bitmap_fe = NULL; 298 + } 299 + } 300 + 301 + static void udf_sb_free_partitions(struct super_block *sb) 302 + { 303 + struct udf_sb_info *sbi = UDF_SB(sb); 304 + int i; 305 + 306 + for (i = 0; i < sbi->s_partitions; i++) 307 + udf_free_partition(&sbi->s_partmaps[i]); 308 + kfree(sbi->s_partmaps); 309 + sbi->s_partmaps = NULL; 310 + } 311 + 255 312 static int udf_show_options(struct seq_file *seq, struct dentry *root) 256 313 { 257 314 struct super_block *sb = root->d_sb; ··· 1340 1283 BUG_ON(ident != TAG_IDENT_LVD); 1341 1284 lvd = (struct logicalVolDesc *)bh->b_data; 1342 1285 table_len = le32_to_cpu(lvd->mapTableLength); 1343 - if (sizeof(*lvd) + table_len > sb->s_blocksize) { 1286 + if (table_len > sb->s_blocksize - sizeof(*lvd)) { 1344 1287 udf_err(sb, "error loading logical volume descriptor: " 1345 1288 "Partition table too long (%u > %lu)\n", table_len, 1346 1289 sb->s_blocksize - sizeof(*lvd)); ··· 1653 1596 /* responsible for finding the PartitionDesc(s) */ 1654 1597 if (!udf_process_sequence(sb, main_s, main_e, fileset)) 1655 1598 return 1; 1656 - return !udf_process_sequence(sb, reserve_s, reserve_e, fileset); 1599 + udf_sb_free_partitions(sb); 1600 + if (!udf_process_sequence(sb, reserve_s, reserve_e, fileset)) 1601 + return 1; 1602 + udf_sb_free_partitions(sb); 1603 + return 0; 1657 1604 } 1658 1605 1659 1606 /* ··· 1922 1861 return ret; 1923 1862 } 1924 1863 1925 - static void udf_sb_free_bitmap(struct udf_bitmap *bitmap) 1926 - { 1927 - int i; 1928 - int nr_groups = bitmap->s_nr_groups; 1929 - int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) * 1930 - nr_groups); 1931 - 1932 - for (i = 0; i < nr_groups; i++) 1933 - if (bitmap->s_block_bitmap[i]) 1934 - brelse(bitmap->s_block_bitmap[i]); 1935 - 1936 - if (size <= PAGE_SIZE) 1937 - kfree(bitmap); 1938 - else 1939 - vfree(bitmap); 1940 - } 1941 - 1942 - static void udf_free_partition(struct udf_part_map *map) 1943 - { 1944 - int i; 1945 - struct udf_meta_data *mdata; 1946 - 1947 - if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) 1948 - iput(map->s_uspace.s_table); 1949 - if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) 1950 - iput(map->s_fspace.s_table); 1951 - if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) 1952 - udf_sb_free_bitmap(map->s_uspace.s_bitmap); 1953 - if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) 1954 - udf_sb_free_bitmap(map->s_fspace.s_bitmap); 1955 - if (map->s_partition_type == UDF_SPARABLE_MAP15) 1956 - for (i = 0; i < 4; i++) 1957 - brelse(map->s_type_specific.s_sparing.s_spar_map[i]); 1958 - else if (map->s_partition_type == UDF_METADATA_MAP25) { 1959 - mdata = &map->s_type_specific.s_metadata; 1960 - iput(mdata->s_metadata_fe); 1961 - mdata->s_metadata_fe = NULL; 1962 - 1963 - iput(mdata->s_mirror_fe); 1964 - mdata->s_mirror_fe = NULL; 1965 - 1966 - iput(mdata->s_bitmap_fe); 1967 - mdata->s_bitmap_fe = NULL; 1968 - } 1969 - } 1970 - 1971 1864 static int udf_fill_super(struct super_block *sb, void *options, int silent) 1972 1865 { 1973 - int i; 1974 1866 int ret; 1975 1867 struct inode *inode = NULL; 1976 1868 struct udf_options uopt; ··· 1988 1974 sb->s_op = &udf_sb_ops; 1989 1975 sb->s_export_op = &udf_export_ops; 1990 1976 1991 - sb->s_dirt = 0; 1992 1977 sb->s_magic = UDF_SUPER_MAGIC; 1993 1978 sb->s_time_gran = 1000; 1994 1979 ··· 2085 2072 error_out: 2086 2073 if (sbi->s_vat_inode) 2087 2074 iput(sbi->s_vat_inode); 2088 - if (sbi->s_partitions) 2089 - for (i = 0; i < sbi->s_partitions; i++) 2090 - udf_free_partition(&sbi->s_partmaps[i]); 2091 2075 #ifdef CONFIG_UDF_NLS 2092 2076 if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) 2093 2077 unload_nls(sbi->s_nls_map); ··· 2092 2082 if (!(sb->s_flags & MS_RDONLY)) 2093 2083 udf_close_lvid(sb); 2094 2084 brelse(sbi->s_lvid_bh); 2095 - 2096 - kfree(sbi->s_partmaps); 2085 + udf_sb_free_partitions(sb); 2097 2086 kfree(sbi); 2098 2087 sb->s_fs_info = NULL; 2099 2088 ··· 2104 2095 { 2105 2096 struct va_format vaf; 2106 2097 va_list args; 2107 - 2108 - /* mark sb error */ 2109 - if (!(sb->s_flags & MS_RDONLY)) 2110 - sb->s_dirt = 1; 2111 2098 2112 2099 va_start(args, fmt); 2113 2100 ··· 2133 2128 2134 2129 static void udf_put_super(struct super_block *sb) 2135 2130 { 2136 - int i; 2137 2131 struct udf_sb_info *sbi; 2138 2132 2139 2133 sbi = UDF_SB(sb); 2140 2134 2141 2135 if (sbi->s_vat_inode) 2142 2136 iput(sbi->s_vat_inode); 2143 - if (sbi->s_partitions) 2144 - for (i = 0; i < sbi->s_partitions; i++) 2145 - udf_free_partition(&sbi->s_partmaps[i]); 2146 2137 #ifdef CONFIG_UDF_NLS 2147 2138 if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) 2148 2139 unload_nls(sbi->s_nls_map); ··· 2146 2145 if (!(sb->s_flags & MS_RDONLY)) 2147 2146 udf_close_lvid(sb); 2148 2147 brelse(sbi->s_lvid_bh); 2149 - kfree(sbi->s_partmaps); 2148 + udf_sb_free_partitions(sb); 2150 2149 kfree(sb->s_fs_info); 2151 2150 sb->s_fs_info = NULL; 2152 2151 } ··· 2162 2161 * the buffer for IO 2163 2162 */ 2164 2163 mark_buffer_dirty(sbi->s_lvid_bh); 2165 - sb->s_dirt = 0; 2166 2164 sbi->s_lvid_dirty = 0; 2167 2165 } 2168 2166 mutex_unlock(&sbi->s_alloc_mutex);
+2 -2
fs/udf/truncate.c
··· 248 248 /* We managed to free all extents in the 249 249 * indirect extent - free it too */ 250 250 BUG_ON(!epos.bh); 251 - udf_free_blocks(sb, inode, &epos.block, 251 + udf_free_blocks(sb, NULL, &epos.block, 252 252 0, indirect_ext_len); 253 253 } else if (!epos.bh) { 254 254 iinfo->i_lenAlloc = lenalloc; ··· 275 275 276 276 if (indirect_ext_len) { 277 277 BUG_ON(!epos.bh); 278 - udf_free_blocks(sb, inode, &epos.block, 0, indirect_ext_len); 278 + udf_free_blocks(sb, NULL, &epos.block, 0, indirect_ext_len); 279 279 } else if (!epos.bh) { 280 280 iinfo->i_lenAlloc = lenalloc; 281 281 mark_inode_dirty(inode);
-1
fs/udf/udfdecl.h
··· 129 129 WARN_ON_ONCE(((struct logicalVolIntegrityDesc *) 130 130 bh->b_data)->integrityType != 131 131 cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN)); 132 - sb->s_dirt = 1; 133 132 UDF_SB(sb)->s_lvid_dirty = 1; 134 133 } 135 134 extern u64 lvid_get_unique_id(struct super_block *sb);