diff options
author | Thomas Meyer <thomas@m3y3r.de> | 2011-11-17 18:00:52 -0500 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2011-11-22 03:58:48 -0500 |
commit | eaecf43a6970c8d0ef54a31427c82a99e4863fe8 (patch) | |
tree | 998f383df3a68c34e08efb5064dfc82536af5a48 /fs/ubifs/lpt.c | |
parent | cfcfc9eca2bcbd26a8e206baeb005b055dbf8e37 (diff) |
UBIFS: Use kmemdup rather than duplicating its implementation
The semantic patch that makes this change is available
in scripts/coccinelle/api/memdup.cocci.
Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'fs/ubifs/lpt.c')
-rw-r--r-- | fs/ubifs/lpt.c | 6 |
1 files changed, 2 insertions, 4 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; |