aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ubifs/lpt_commit.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/fs/ubifs/lpt_commit.c b/fs/ubifs/lpt_commit.c
index 62a38d9c55e9..0a3c2c3f5c4a 100644
--- a/fs/ubifs/lpt_commit.c
+++ b/fs/ubifs/lpt_commit.c
@@ -1881,25 +1881,31 @@ int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len)
1881static void dump_lpt_leb(const struct ubifs_info *c, int lnum) 1881static void dump_lpt_leb(const struct ubifs_info *c, int lnum)
1882{ 1882{
1883 int err, len = c->leb_size, node_type, node_num, node_len, offs; 1883 int err, len = c->leb_size, node_type, node_num, node_len, offs;
1884 void *buf = c->dbg->buf; 1884 void *buf, *p;
1885 1885
1886 printk(KERN_DEBUG "(pid %d) start dumping LEB %d\n", 1886 printk(KERN_DEBUG "(pid %d) start dumping LEB %d\n",
1887 current->pid, lnum); 1887 current->pid, lnum);
1888 buf = p = __vmalloc(c->leb_size, GFP_KERNEL | GFP_NOFS, PAGE_KERNEL);
1889 if (!buf) {
1890 ubifs_err("cannot allocate memory to dump LPT");
1891 return;
1892 }
1893
1888 err = ubi_read(c->ubi, lnum, buf, 0, c->leb_size); 1894 err = ubi_read(c->ubi, lnum, buf, 0, c->leb_size);
1889 if (err) { 1895 if (err) {
1890 ubifs_err("cannot read LEB %d, error %d", lnum, err); 1896 ubifs_err("cannot read LEB %d, error %d", lnum, err);
1891 return; 1897 goto out;
1892 } 1898 }
1893 while (1) { 1899 while (1) {
1894 offs = c->leb_size - len; 1900 offs = c->leb_size - len;
1895 if (!is_a_node(c, buf, len)) { 1901 if (!is_a_node(c, p, len)) {
1896 int pad_len; 1902 int pad_len;
1897 1903
1898 pad_len = get_pad_len(c, buf, len); 1904 pad_len = get_pad_len(c, p, len);
1899 if (pad_len) { 1905 if (pad_len) {
1900 printk(KERN_DEBUG "LEB %d:%d, pad %d bytes\n", 1906 printk(KERN_DEBUG "LEB %d:%d, pad %d bytes\n",
1901 lnum, offs, pad_len); 1907 lnum, offs, pad_len);
1902 buf += pad_len; 1908 p += pad_len;
1903 len -= pad_len; 1909 len -= pad_len;
1904 continue; 1910 continue;
1905 } 1911 }
@@ -1909,7 +1915,7 @@ static void dump_lpt_leb(const struct ubifs_info *c, int lnum)
1909 break; 1915 break;
1910 } 1916 }
1911 1917
1912 node_type = get_lpt_node_type(c, buf, &node_num); 1918 node_type = get_lpt_node_type(c, p, &node_num);
1913 switch (node_type) { 1919 switch (node_type) {
1914 case UBIFS_LPT_PNODE: 1920 case UBIFS_LPT_PNODE:
1915 { 1921 {
@@ -1934,7 +1940,7 @@ static void dump_lpt_leb(const struct ubifs_info *c, int lnum)
1934 else 1940 else
1935 printk(KERN_DEBUG "LEB %d:%d, nnode, ", 1941 printk(KERN_DEBUG "LEB %d:%d, nnode, ",
1936 lnum, offs); 1942 lnum, offs);
1937 err = ubifs_unpack_nnode(c, buf, &nnode); 1943 err = ubifs_unpack_nnode(c, p, &nnode);
1938 for (i = 0; i < UBIFS_LPT_FANOUT; i++) { 1944 for (i = 0; i < UBIFS_LPT_FANOUT; i++) {
1939 printk(KERN_CONT "%d:%d", nnode.nbranch[i].lnum, 1945 printk(KERN_CONT "%d:%d", nnode.nbranch[i].lnum,
1940 nnode.nbranch[i].offs); 1946 nnode.nbranch[i].offs);
@@ -1955,15 +1961,18 @@ static void dump_lpt_leb(const struct ubifs_info *c, int lnum)
1955 break; 1961 break;
1956 default: 1962 default:
1957 ubifs_err("LPT node type %d not recognized", node_type); 1963 ubifs_err("LPT node type %d not recognized", node_type);
1958 return; 1964 goto out;
1959 } 1965 }
1960 1966
1961 buf += node_len; 1967 p += node_len;
1962 len -= node_len; 1968 len -= node_len;
1963 } 1969 }
1964 1970
1965 printk(KERN_DEBUG "(pid %d) finish dumping LEB %d\n", 1971 printk(KERN_DEBUG "(pid %d) finish dumping LEB %d\n",
1966 current->pid, lnum); 1972 current->pid, lnum);
1973out:
1974 vfree(buf);
1975 return;
1967} 1976}
1968 1977
1969/** 1978/**