aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-01-10 17:57:19 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-10 17:57:19 -0500
commit5c395ae7033099fc657114ea997858aa622f08b2 (patch)
treef714c8d8db528274de2da4f8aa64b69af0d2aa5e /fs/ubifs
parent49d41bae46f15da528ef9848fd7c9d38582aa8e9 (diff)
parente57e0d8e818512047fe379157c3f77f1b9fabffb (diff)
Merge branch 'linux-next' of git://git.infradead.org/ubifs-2.6
* 'linux-next' of git://git.infradead.org/ubifs-2.6: UBI: fix use-after-free on error path UBI: fix missing scrub when there is a bit-flip UBIFS: Use kmemdup rather than duplicating its implementation
Diffstat (limited to 'fs/ubifs')
-rw-r--r--fs/ubifs/lpt.c6
-rw-r--r--fs/ubifs/tnc.c3
-rw-r--r--fs/ubifs/xattr.c6
3 files changed, 5 insertions, 10 deletions
diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c
index 6189c74d97f0..66d59d0a1402 100644
--- a/fs/ubifs/lpt.c
+++ b/fs/ubifs/lpt.c
@@ -1986,12 +1986,11 @@ again:
1986 1986
1987 if (path[h].in_tree) 1987 if (path[h].in_tree)
1988 continue; 1988 continue;
1989 nnode = kmalloc(sz, GFP_NOFS); 1989 nnode = kmemdup(&path[h].nnode, sz, GFP_NOFS);
1990 if (!nnode) { 1990 if (!nnode) {
1991 err = -ENOMEM; 1991 err = -ENOMEM;
1992 goto out; 1992 goto out;
1993 } 1993 }
1994 memcpy(nnode, &path[h].nnode, sz);
1995 parent = nnode->parent; 1994 parent = nnode->parent;
1996 parent->nbranch[nnode->iip].nnode = nnode; 1995 parent->nbranch[nnode->iip].nnode = nnode;
1997 path[h].ptr.nnode = nnode; 1996 path[h].ptr.nnode = nnode;
@@ -2004,12 +2003,11 @@ again:
2004 const size_t sz = sizeof(struct ubifs_pnode); 2003 const size_t sz = sizeof(struct ubifs_pnode);
2005 struct ubifs_nnode *parent; 2004 struct ubifs_nnode *parent;
2006 2005
2007 pnode = kmalloc(sz, GFP_NOFS); 2006 pnode = kmemdup(&path[h].pnode, sz, GFP_NOFS);
2008 if (!pnode) { 2007 if (!pnode) {
2009 err = -ENOMEM; 2008 err = -ENOMEM;
2010 goto out; 2009 goto out;
2011 } 2010 }
2012 memcpy(pnode, &path[h].pnode, sz);
2013 parent = pnode->parent; 2011 parent = pnode->parent;
2014 parent->nbranch[pnode->iip].pnode = pnode; 2012 parent->nbranch[pnode->iip].pnode = pnode;
2015 path[h].ptr.pnode = pnode; 2013 path[h].ptr.pnode = pnode;
diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c
index 066738647685..e14ee53159db 100644
--- a/fs/ubifs/tnc.c
+++ b/fs/ubifs/tnc.c
@@ -344,12 +344,11 @@ static int lnc_add(struct ubifs_info *c, struct ubifs_zbranch *zbr,
344 return err; 344 return err;
345 } 345 }
346 346
347 lnc_node = kmalloc(zbr->len, GFP_NOFS); 347 lnc_node = kmemdup(node, zbr->len, GFP_NOFS);
348 if (!lnc_node) 348 if (!lnc_node)
349 /* We don't have to have the cache, so no error */ 349 /* We don't have to have the cache, so no error */
350 return 0; 350 return 0;
351 351
352 memcpy(lnc_node, node, zbr->len);
353 zbr->leaf = lnc_node; 352 zbr->leaf = lnc_node;
354 return 0; 353 return 0;
355} 354}
diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
index bf18f7a04544..85b272268754 100644
--- a/fs/ubifs/xattr.c
+++ b/fs/ubifs/xattr.c
@@ -138,12 +138,11 @@ static int create_xattr(struct ubifs_info *c, struct inode *host,
138 ui = ubifs_inode(inode); 138 ui = ubifs_inode(inode);
139 ui->xattr = 1; 139 ui->xattr = 1;
140 ui->flags |= UBIFS_XATTR_FL; 140 ui->flags |= UBIFS_XATTR_FL;
141 ui->data = kmalloc(size, GFP_NOFS); 141 ui->data = kmemdup(value, size, GFP_NOFS);
142 if (!ui->data) { 142 if (!ui->data) {
143 err = -ENOMEM; 143 err = -ENOMEM;
144 goto out_free; 144 goto out_free;
145 } 145 }
146 memcpy(ui->data, value, size);
147 inode->i_size = ui->ui_size = size; 146 inode->i_size = ui->ui_size = size;
148 ui->data_len = size; 147 ui->data_len = size;
149 148
@@ -204,12 +203,11 @@ static int change_xattr(struct ubifs_info *c, struct inode *host,
204 return err; 203 return err;
205 204
206 kfree(ui->data); 205 kfree(ui->data);
207 ui->data = kmalloc(size, GFP_NOFS); 206 ui->data = kmemdup(value, size, GFP_NOFS);
208 if (!ui->data) { 207 if (!ui->data) {
209 err = -ENOMEM; 208 err = -ENOMEM;
210 goto out_free; 209 goto out_free;
211 } 210 }
212 memcpy(ui->data, value, size);
213 inode->i_size = ui->ui_size = size; 211 inode->i_size = ui->ui_size = size;
214 ui->data_len = size; 212 ui->data_len = size;
215 213