map.c (14da17f9c4a880e3418f7f04071df3cb2e8636e8) | map.c (a19189e5535ed8fd191d8989fc39da1637cfa224) |
---|---|
1/* 2 * linux/fs/hpfs/map.c 3 * 4 * Mikulas Patocka (mikulas@artax.karlin.mff.cuni.cz), 1998-1999 5 * 6 * mapping structures to memory with some minimal checks 7 */ 8 --- 51 unchanged lines hidden (view full) --- 60 unsigned cpi; 61 unsigned char *ptr; 62 unsigned char *cp_table; 63 int i; 64 struct code_page_data *cpd; 65 struct code_page_directory *cp = hpfs_map_sector(s, cps, &bh, 0); 66 if (!cp) return NULL; 67 if (le32_to_cpu(cp->magic) != CP_DIR_MAGIC) { | 1/* 2 * linux/fs/hpfs/map.c 3 * 4 * Mikulas Patocka (mikulas@artax.karlin.mff.cuni.cz), 1998-1999 5 * 6 * mapping structures to memory with some minimal checks 7 */ 8 --- 51 unchanged lines hidden (view full) --- 60 unsigned cpi; 61 unsigned char *ptr; 62 unsigned char *cp_table; 63 int i; 64 struct code_page_data *cpd; 65 struct code_page_directory *cp = hpfs_map_sector(s, cps, &bh, 0); 66 if (!cp) return NULL; 67 if (le32_to_cpu(cp->magic) != CP_DIR_MAGIC) { |
68 pr_warn("Code page directory magic doesn't match (magic = %08x)\n", | 68 pr_err("Code page directory magic doesn't match (magic = %08x)\n", |
69 le32_to_cpu(cp->magic)); 70 brelse(bh); 71 return NULL; 72 } 73 if (!le32_to_cpu(cp->n_code_pages)) { | 69 le32_to_cpu(cp->magic)); 70 brelse(bh); 71 return NULL; 72 } 73 if (!le32_to_cpu(cp->n_code_pages)) { |
74 pr_warn("n_code_pages == 0\n"); | 74 pr_err("n_code_pages == 0\n"); |
75 brelse(bh); 76 return NULL; 77 } 78 cpds = le32_to_cpu(cp->array[0].code_page_data); 79 cpi = le16_to_cpu(cp->array[0].index); 80 brelse(bh); 81 82 if (cpi >= 3) { | 75 brelse(bh); 76 return NULL; 77 } 78 cpds = le32_to_cpu(cp->array[0].code_page_data); 79 cpi = le16_to_cpu(cp->array[0].index); 80 brelse(bh); 81 82 if (cpi >= 3) { |
83 pr_warn("Code page index out of array\n"); | 83 pr_err("Code page index out of array\n"); |
84 return NULL; 85 } 86 87 if (!(cpd = hpfs_map_sector(s, cpds, &bh, 0))) return NULL; 88 if (le16_to_cpu(cpd->offs[cpi]) > 0x178) { | 84 return NULL; 85 } 86 87 if (!(cpd = hpfs_map_sector(s, cpds, &bh, 0))) return NULL; 88 if (le16_to_cpu(cpd->offs[cpi]) > 0x178) { |
89 pr_warn("Code page index out of sector\n"); | 89 pr_err("Code page index out of sector\n"); |
90 brelse(bh); 91 return NULL; 92 } 93 ptr = (unsigned char *)cpd + le16_to_cpu(cpd->offs[cpi]) + 6; 94 if (!(cp_table = kmalloc(256, GFP_KERNEL))) { | 90 brelse(bh); 91 return NULL; 92 } 93 ptr = (unsigned char *)cpd + le16_to_cpu(cpd->offs[cpi]) + 6; 94 if (!(cp_table = kmalloc(256, GFP_KERNEL))) { |
95 pr_warn("out of memory for code page table\n"); | 95 pr_err("out of memory for code page table\n"); |
96 brelse(bh); 97 return NULL; 98 } 99 memcpy(cp_table, ptr, 128); 100 brelse(bh); 101 102 /* Try to build lowercasing table from uppercasing one */ 103 --- 6 unchanged lines hidden (view full) --- 110 111__le32 *hpfs_load_bitmap_directory(struct super_block *s, secno bmp) 112{ 113 struct buffer_head *bh; 114 int n = (hpfs_sb(s)->sb_fs_size + 0x200000 - 1) >> 21; 115 int i; 116 __le32 *b; 117 if (!(b = kmalloc(n * 512, GFP_KERNEL))) { | 96 brelse(bh); 97 return NULL; 98 } 99 memcpy(cp_table, ptr, 128); 100 brelse(bh); 101 102 /* Try to build lowercasing table from uppercasing one */ 103 --- 6 unchanged lines hidden (view full) --- 110 111__le32 *hpfs_load_bitmap_directory(struct super_block *s, secno bmp) 112{ 113 struct buffer_head *bh; 114 int n = (hpfs_sb(s)->sb_fs_size + 0x200000 - 1) >> 21; 115 int i; 116 __le32 *b; 117 if (!(b = kmalloc(n * 512, GFP_KERNEL))) { |
118 pr_warn("can't allocate memory for bitmap directory\n"); | 118 pr_err("can't allocate memory for bitmap directory\n"); |
119 return NULL; 120 } 121 for (i=0;i<n;i++) { 122 __le32 *d = hpfs_map_sector(s, bmp+i, &bh, n - i - 1); 123 if (!d) { 124 kfree(b); 125 return NULL; 126 } --- 151 unchanged lines hidden (view full) --- 278 hpfs_error(s, "size on last dirent does not match first_free; dnode %08x", secno); 279 goto bail; 280 } 281 if (d[pp + 30] != 1 || d[pp + 31] != 255) { 282 hpfs_error(s, "dnode %08x does not end with \\377 entry", secno); 283 goto bail; 284 } 285 if (b == 3) | 119 return NULL; 120 } 121 for (i=0;i<n;i++) { 122 __le32 *d = hpfs_map_sector(s, bmp+i, &bh, n - i - 1); 123 if (!d) { 124 kfree(b); 125 return NULL; 126 } --- 151 unchanged lines hidden (view full) --- 278 hpfs_error(s, "size on last dirent does not match first_free; dnode %08x", secno); 279 goto bail; 280 } 281 if (d[pp + 30] != 1 || d[pp + 31] != 255) { 282 hpfs_error(s, "dnode %08x does not end with \\377 entry", secno); 283 goto bail; 284 } 285 if (b == 3) |
286 pr_warn("unbalanced dnode tree, dnode %08x; see hpfs.txt 4 more info\n", | 286 pr_err("unbalanced dnode tree, dnode %08x; see hpfs.txt 4 more info\n", |
287 secno); 288 } 289 return dnode; 290 bail: 291 hpfs_brelse4(qbh); 292 return NULL; 293} 294 --- 14 unchanged lines hidden --- | 287 secno); 288 } 289 return dnode; 290 bail: 291 hpfs_brelse4(qbh); 292 return NULL; 293} 294 --- 14 unchanged lines hidden --- |