Skip to content

Commit

Permalink
UBIFS: use kmemdup rather than duplicating its implementation
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Richard Weinberger <[email protected]>
Signed-off-by: Artem Bityutskiy <[email protected]>
  • Loading branch information
Andrzej Hajda authored and richardweinberger committed Oct 3, 2015
1 parent 9ffecb1 commit bbc8a00
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
6 changes: 2 additions & 4 deletions fs/ubifs/lpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1498,11 +1498,10 @@ static struct ubifs_nnode *dirty_cow_nnode(struct ubifs_info *c,
}

/* nnode is being committed, so copy it */
n = kmalloc(sizeof(struct ubifs_nnode), GFP_NOFS);
n = kmemdup(nnode, sizeof(struct ubifs_nnode), GFP_NOFS);
if (unlikely(!n))
return ERR_PTR(-ENOMEM);

memcpy(n, nnode, sizeof(struct ubifs_nnode));
n->cnext = NULL;
__set_bit(DIRTY_CNODE, &n->flags);
__clear_bit(COW_CNODE, &n->flags);
Expand Down Expand Up @@ -1549,11 +1548,10 @@ static struct ubifs_pnode *dirty_cow_pnode(struct ubifs_info *c,
}

/* pnode is being committed, so copy it */
p = kmalloc(sizeof(struct ubifs_pnode), GFP_NOFS);
p = kmemdup(pnode, sizeof(struct ubifs_pnode), GFP_NOFS);
if (unlikely(!p))
return ERR_PTR(-ENOMEM);

memcpy(p, pnode, sizeof(struct ubifs_pnode));
p->cnext = NULL;
__set_bit(DIRTY_CNODE, &p->flags);
__clear_bit(COW_CNODE, &p->flags);
Expand Down
3 changes: 1 addition & 2 deletions fs/ubifs/tnc.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,10 @@ static struct ubifs_znode *copy_znode(struct ubifs_info *c,
{
struct ubifs_znode *zn;

zn = kmalloc(c->max_znode_sz, GFP_NOFS);
zn = kmemdup(znode, c->max_znode_sz, GFP_NOFS);
if (unlikely(!zn))
return ERR_PTR(-ENOMEM);

memcpy(zn, znode, c->max_znode_sz);
zn->cnext = NULL;
__set_bit(DIRTY_ZNODE, &zn->flags);
__clear_bit(COW_ZNODE, &zn->flags);
Expand Down

0 comments on commit bbc8a00

Please sign in to comment.