[PATCH] omfs: make use of kmemdup

From: Saiyam Doshi
Date: Fri Sep 13 2019 - 13:11:49 EST


Replace call to kmalloc followed by memcpy with a direct call
to kmemdup to achieve same functionality.

Signed-off-by: Saiyam Doshi <saiyamdoshi.in@xxxxxxxxx>
---
fs/omfs/inode.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c
index b76ec6b88ded..788b41096962 100644
--- a/fs/omfs/inode.c
+++ b/fs/omfs/inode.c
@@ -363,12 +363,13 @@ static int omfs_get_imap(struct super_block *sb)
bh = sb_bread(sb, block++);
if (!bh)
goto nomem_free;
- *ptr = kmalloc(sb->s_blocksize, GFP_KERNEL);
+
+ *ptr = kmemdup(bh->b_data, sb->s_blocksize, GFP_KERNEL);
if (!*ptr) {
brelse(bh);
goto nomem_free;
}
- memcpy(*ptr, bh->b_data, sb->s_blocksize);
+
if (count < sb->s_blocksize)
memset((void *)*ptr + count, 0xff,
sb->s_blocksize - count);
--
2.20.1