diff options
author | Andrzej Hajda <a.hajda@samsung.com> | 2015-08-07 03:59:31 -0400 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2015-10-03 14:03:14 -0400 |
commit | bbc8a0044fb27da5fadb7efbfb472aed00c58e72 (patch) | |
tree | 65097afa4e508ec629c26bdf3302cb9d510220e0 | |
parent | 9ffecb10283508260936b96022d4ee43a7798b4c (diff) |
UBIFS: use kmemdup rather than duplicating its implementation
The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].
[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Reviewed-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
-rw-r--r-- | fs/ubifs/lpt.c | 6 | ||||
-rw-r--r-- | fs/ubifs/tnc.c | 3 |
2 files changed, 3 insertions, 6 deletions
diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c index dc9f27e9d61b..9a517109da0f 100644 --- a/fs/ubifs/lpt.c +++ b/fs/ubifs/lpt.c | |||
@@ -1498,11 +1498,10 @@ static struct ubifs_nnode *dirty_cow_nnode(struct ubifs_info *c, | |||
1498 | } | 1498 | } |
1499 | 1499 | ||
1500 | /* nnode is being committed, so copy it */ | 1500 | /* nnode is being committed, so copy it */ |
1501 | n = kmalloc(sizeof(struct ubifs_nnode), GFP_NOFS); | 1501 | n = kmemdup(nnode, sizeof(struct ubifs_nnode), GFP_NOFS); |
1502 | if (unlikely(!n)) | 1502 | if (unlikely(!n)) |
1503 | return ERR_PTR(-ENOMEM); | 1503 | return ERR_PTR(-ENOMEM); |
1504 | 1504 | ||
1505 | memcpy(n, nnode, sizeof(struct ubifs_nnode)); | ||
1506 | n->cnext = NULL; | 1505 | n->cnext = NULL; |
1507 | __set_bit(DIRTY_CNODE, &n->flags); | 1506 | __set_bit(DIRTY_CNODE, &n->flags); |
1508 | __clear_bit(COW_CNODE, &n->flags); | 1507 | __clear_bit(COW_CNODE, &n->flags); |
@@ -1549,11 +1548,10 @@ static struct ubifs_pnode *dirty_cow_pnode(struct ubifs_info *c, | |||
1549 | } | 1548 | } |
1550 | 1549 | ||
1551 | /* pnode is being committed, so copy it */ | 1550 | /* pnode is being committed, so copy it */ |
1552 | p = kmalloc(sizeof(struct ubifs_pnode), GFP_NOFS); | 1551 | p = kmemdup(pnode, sizeof(struct ubifs_pnode), GFP_NOFS); |
1553 | if (unlikely(!p)) | 1552 | if (unlikely(!p)) |
1554 | return ERR_PTR(-ENOMEM); | 1553 | return ERR_PTR(-ENOMEM); |
1555 | 1554 | ||
1556 | memcpy(p, pnode, sizeof(struct ubifs_pnode)); | ||
1557 | p->cnext = NULL; | 1555 | p->cnext = NULL; |
1558 | __set_bit(DIRTY_CNODE, &p->flags); | 1556 | __set_bit(DIRTY_CNODE, &p->flags); |
1559 | __clear_bit(COW_CNODE, &p->flags); | 1557 | __clear_bit(COW_CNODE, &p->flags); |
diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c index 957f5757f374..fa9a20cc60d6 100644 --- a/fs/ubifs/tnc.c +++ b/fs/ubifs/tnc.c | |||
@@ -198,11 +198,10 @@ static struct ubifs_znode *copy_znode(struct ubifs_info *c, | |||
198 | { | 198 | { |
199 | struct ubifs_znode *zn; | 199 | struct ubifs_znode *zn; |
200 | 200 | ||
201 | zn = kmalloc(c->max_znode_sz, GFP_NOFS); | 201 | zn = kmemdup(znode, c->max_znode_sz, GFP_NOFS); |
202 | if (unlikely(!zn)) | 202 | if (unlikely(!zn)) |
203 | return ERR_PTR(-ENOMEM); | 203 | return ERR_PTR(-ENOMEM); |
204 | 204 | ||
205 | memcpy(zn, znode, c->max_znode_sz); | ||
206 | zn->cnext = NULL; | 205 | zn->cnext = NULL; |
207 | __set_bit(DIRTY_ZNODE, &zn->flags); | 206 | __set_bit(DIRTY_ZNODE, &zn->flags); |
208 | __clear_bit(COW_ZNODE, &zn->flags); | 207 | __clear_bit(COW_ZNODE, &zn->flags); |