ARM: 6165/1: trap overflows on highmem pages from kmap_atomic when debugging
[safe/jmp/linux-2.6] / fs / hpfs / dnode.c
index 1d21307..9b2ffad 100644 (file)
@@ -158,7 +158,8 @@ static void set_last_pointer(struct super_block *s, struct dnode *d, dnode_secno
 
 /* Add an entry to dnode and don't care if it grows over 2048 bytes */
 
-struct hpfs_dirent *hpfs_add_de(struct super_block *s, struct dnode *d, unsigned char *name,
+struct hpfs_dirent *hpfs_add_de(struct super_block *s, struct dnode *d,
+                               const unsigned char *name,
                                unsigned namelen, secno down_ptr)
 {
        struct hpfs_dirent *de;
@@ -223,7 +224,7 @@ static void fix_up_ptrs(struct super_block *s, struct dnode *d)
 /* Add an entry to dnode and do dnode splitting if required */
 
 static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno,
-                            unsigned char *name, unsigned namelen,
+                            const unsigned char *name, unsigned namelen,
                             struct hpfs_dirent *new_de, dnode_secno down_ptr)
 {
        struct quad_buffer_head qbh, qbh1, qbh2;
@@ -231,7 +232,7 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno,
        dnode_secno adno, rdno;
        struct hpfs_dirent *de;
        struct hpfs_dirent nde;
-       char *nname;
+       unsigned char *nname;
        int h;
        int pos;
        struct buffer_head *bh;
@@ -244,12 +245,12 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno,
        go_up:
        if (namelen >= 256) {
                hpfs_error(i->i_sb, "hpfs_add_to_dnode: namelen == %d", namelen);
-               if (nd) kfree(nd);
+               kfree(nd);
                kfree(nname);
                return 1;
        }
        if (!(d = hpfs_map_dnode(i->i_sb, dno, &qbh))) {
-               if (nd) kfree(nd);
+               kfree(nd);
                kfree(nname);
                return 1;
        }
@@ -257,7 +258,7 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno,
        if (hpfs_sb(i->i_sb)->sb_chk)
                if (hpfs_stop_cycles(i->i_sb, dno, &c1, &c2, "hpfs_add_to_dnode")) {
                        hpfs_brelse4(&qbh);
-                       if (nd) kfree(nd);
+                       kfree(nd);
                        kfree(nname);
                        return 1;
                }
@@ -270,7 +271,7 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno,
                for_all_poss(i, hpfs_pos_subst, 5, t + 1);
                hpfs_mark_4buffers_dirty(&qbh);
                hpfs_brelse4(&qbh);
-               if (nd) kfree(nd);
+               kfree(nd);
                kfree(nname);
                return 0;
        }
@@ -305,7 +306,9 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno,
                pos++;
        }
        copy_de(new_de = &nde, de);
-       memcpy(name = nname, de->name, namelen = de->namelen);
+       memcpy(nname, de->name, de->namelen);
+       name = nname;
+       namelen = de->namelen;
        for_all_poss(i, hpfs_pos_subst, ((loff_t)dno << 4) | pos, 4);
        down_ptr = adno;
        set_last_pointer(i->i_sb, ad, de->down ? de_down_pointer(de) : 0);
@@ -368,7 +371,8 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno,
  * I hope, now it's finally bug-free.
  */
 
-int hpfs_add_dirent(struct inode *i, unsigned char *name, unsigned namelen,
+int hpfs_add_dirent(struct inode *i,
+                   const unsigned char *name, unsigned namelen,
                    struct hpfs_dirent *new_de, int cdepth)
 {
        struct hpfs_inode_info *hpfs_inode = hpfs_i(i);
@@ -533,10 +537,13 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno)
                        struct buffer_head *bh;
                        struct dnode *d1;
                        struct quad_buffer_head qbh1;
-                       if (hpfs_sb(i->i_sb)->sb_chk) if (up != i->i_ino) {
-                               hpfs_error(i->i_sb, "bad pointer to fnode, dnode %08x, pointing to %08x, should be %08x", dno, up, i->i_ino);
+                       if (hpfs_sb(i->i_sb)->sb_chk)
+                           if (up != i->i_ino) {
+                               hpfs_error(i->i_sb,
+                                       "bad pointer to fnode, dnode %08x, pointing to %08x, should be %08lx",
+                                       dno, up, (unsigned long)i->i_ino);
                                return;
-                       }
+                           }
                        if ((d1 = hpfs_map_dnode(i->i_sb, down, &qbh1))) {
                                d1->up = up;
                                d1->root_dnode = 1;
@@ -851,7 +858,9 @@ struct hpfs_dirent *map_pos_dirent(struct inode *inode, loff_t *posp,
        /* Going to the next dirent */
        if ((d = de_next_de(de)) < dnode_end_de(dnode)) {
                if (!(++*posp & 077)) {
-                       hpfs_error(inode->i_sb, "map_pos_dirent: pos crossed dnode boundary; pos = %08x", *posp);
+                       hpfs_error(inode->i_sb,
+                               "map_pos_dirent: pos crossed dnode boundary; pos = %08llx",
+                               (unsigned long long)*posp);
                        goto bail;
                }
                /* We're going down the tree */
@@ -892,7 +901,8 @@ struct hpfs_dirent *map_pos_dirent(struct inode *inode, loff_t *posp,
 
 /* Find a dirent in tree */
 
-struct hpfs_dirent *map_dirent(struct inode *inode, dnode_secno dno, char *name, unsigned len,
+struct hpfs_dirent *map_dirent(struct inode *inode, dnode_secno dno,
+                              const unsigned char *name, unsigned len,
                               dnode_secno *dd, struct quad_buffer_head *qbh)
 {
        struct dnode *dnode;
@@ -983,8 +993,8 @@ void hpfs_remove_dtree(struct super_block *s, dnode_secno dno)
 struct hpfs_dirent *map_fnode_dirent(struct super_block *s, fnode_secno fno,
                                     struct fnode *f, struct quad_buffer_head *qbh)
 {
-       char *name1;
-       char *name2;
+       unsigned char *name1;
+       unsigned char *name2;
        int name1len, name2len;
        struct dnode *d;
        dnode_secno dno, downd;