aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf
diff options
context:
space:
mode:
authorMarcin Slusarz <marcin.slusarz@gmail.com>2008-02-08 07:20:32 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-08 12:22:35 -0500
commitdc5d39be6dfb54a50c8ee1f6154b10181c974db1 (patch)
treea2bdb6bf78439db84df007b61c33bfdc95501f99 /fs/udf
parent6c79e987d629cb0f8f7e2983725f4434a2dec66b (diff)
udf: convert UDF_SB_ALLOC_PARTMAPS macro to udf_sb_alloc_partition_maps function
- convert UDF_SB_ALLOC_PARTMAPS macro to udf_sb_alloc_partition_maps function - convert kmalloc + memset to kcalloc - check if kcalloc failed (partially) Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com> Cc: Ben Fennema <bfennema@falcon.csc.calpoly.edu> Cc: Jan Kara <jack@suse.cz> Acked-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/udf')
-rw-r--r--fs/udf/super.c25
-rw-r--r--fs/udf/udf_sb.h13
2 files changed, 23 insertions, 15 deletions
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 0ca2deb5b992..4d1e197164b7 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -52,6 +52,7 @@
52#include <linux/buffer_head.h> 52#include <linux/buffer_head.h>
53#include <linux/vfs.h> 53#include <linux/vfs.h>
54#include <linux/vmalloc.h> 54#include <linux/vmalloc.h>
55#include <linux/errno.h>
55#include <asm/byteorder.h> 56#include <asm/byteorder.h>
56 57
57#include <linux/udf_fs.h> 58#include <linux/udf_fs.h>
@@ -226,6 +227,24 @@ static void __exit exit_udf_fs(void)
226module_init(init_udf_fs) 227module_init(init_udf_fs)
227module_exit(exit_udf_fs) 228module_exit(exit_udf_fs)
228 229
230static int udf_sb_alloc_partition_maps(struct super_block *sb, u32 count)
231{
232 struct udf_sb_info *sbi = UDF_SB(sb);
233
234 sbi->s_partmaps = kcalloc(count, sizeof(struct udf_part_map),
235 GFP_KERNEL);
236 if (!sbi->s_partmaps) {
237 udf_error(sb, __FUNCTION__,
238 "Unable to allocate space for %d partition maps",
239 count);
240 sbi->s_partitions = 0;
241 return -ENOMEM;
242 }
243
244 sbi->s_partitions = count;
245 return 0;
246}
247
229/* 248/*
230 * udf_parse_options 249 * udf_parse_options
231 * 250 *
@@ -1037,7 +1056,9 @@ static int udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh,
1037 1056
1038 lvd = (struct logicalVolDesc *)bh->b_data; 1057 lvd = (struct logicalVolDesc *)bh->b_data;
1039 1058
1040 UDF_SB_ALLOC_PARTMAPS(sb, le32_to_cpu(lvd->numPartitionMaps)); 1059 i = udf_sb_alloc_partition_maps(sb, le32_to_cpu(lvd->numPartitionMaps));
1060 if (i != 0)
1061 return i;
1041 1062
1042 for (i = 0, offset = 0; 1063 for (i = 0, offset = 0;
1043 i < sbi->s_partitions && offset < le32_to_cpu(lvd->mapTableLength); 1064 i < sbi->s_partitions && offset < le32_to_cpu(lvd->mapTableLength);
@@ -1242,7 +1263,7 @@ static int udf_process_sequence(struct super_block *sb, long block,
1242 if (i == VDS_POS_PRIMARY_VOL_DESC) { 1263 if (i == VDS_POS_PRIMARY_VOL_DESC) {
1243 udf_load_pvoldesc(sb, bh); 1264 udf_load_pvoldesc(sb, bh);
1244 } else if (i == VDS_POS_LOGICAL_VOL_DESC) { 1265 } else if (i == VDS_POS_LOGICAL_VOL_DESC) {
1245 udf_load_logicalvol(sb, bh, fileset); 1266 udf_load_logicalvol(sb, bh, fileset); /* TODO: check return value */
1246 } else if (i == VDS_POS_PARTITION_DESC) { 1267 } else if (i == VDS_POS_PARTITION_DESC) {
1247 struct buffer_head *bh2 = NULL; 1268 struct buffer_head *bh2 = NULL;
1248 if (udf_load_partdesc(sb, bh)) { 1269 if (udf_load_partdesc(sb, bh)) {
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index 92e6d75b0163..4d3bd77ea94b 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -43,19 +43,6 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb)
43 43
44struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct udf_sb_info *sbi); 44struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct udf_sb_info *sbi);
45 45
46#define UDF_SB_ALLOC_PARTMAPS(X,Y)\
47{\
48 struct udf_sb_info *sbi = UDF_SB(X);\
49 sbi->s_partmaps = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\
50 if (sbi->s_partmaps != NULL) {\
51 sbi->s_partitions = Y;\
52 memset(sbi->s_partmaps, 0x00, sizeof(struct udf_part_map) * Y);\
53 } else {\
54 sbi->s_partitions = 0;\
55 udf_error(X, __FUNCTION__, "Unable to allocate space for %d partition maps", Y);\
56 }\
57}
58
59#define UDF_SB_ALLOC_BITMAP(X,Y,Z)\ 46#define UDF_SB_ALLOC_BITMAP(X,Y,Z)\
60{\ 47{\
61 struct udf_sb_info *sbi = UDF_SB(X);\ 48 struct udf_sb_info *sbi = UDF_SB(X);\