summaryrefslogtreecommitdiff
path: root/fs/ksmbd/vfs.c
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2021-07-07 13:15:32 +0300
committerNamjae Jeon <namjae.jeon@samsung.com>2021-07-10 09:29:13 +0900
commit07781de9051859d2f38a9e199384c64bb1924c47 (patch)
tree8c7c3f31fcbf53946694878196e90475dd0e012c /fs/ksmbd/vfs.c
parent0f6619aee86f11cee0c5063777c4febdf18cb28b (diff)
ksmbd: use kasprintf() in ksmbd_vfs_xattr_stream_name()
Simplify the code by using kasprintf(). This also silences a Smatch warning: fs/ksmbd/vfs.c:1725 ksmbd_vfs_xattr_stream_name() warn: inconsistent indenting Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com> Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/ksmbd/vfs.c')
-rw-r--r--fs/ksmbd/vfs.c27
1 files changed, 6 insertions, 21 deletions
diff --git a/fs/ksmbd/vfs.c b/fs/ksmbd/vfs.c
index 7339d5c74aad..38677c20d048 100644
--- a/fs/ksmbd/vfs.c
+++ b/fs/ksmbd/vfs.c
@@ -1698,35 +1698,20 @@ out:
int ksmbd_vfs_xattr_stream_name(char *stream_name, char **xattr_stream_name,
size_t *xattr_stream_name_size, int s_type)
{
- int stream_name_size;
- char *xattr_stream_name_buf;
- char *type;
- int type_len;
+ char *type, *buf;
if (s_type == DIR_STREAM)
type = ":$INDEX_ALLOCATION";
else
type = ":$DATA";
- type_len = strlen(type);
- stream_name_size = strlen(stream_name);
- *xattr_stream_name_size = stream_name_size + XATTR_NAME_STREAM_LEN + 1;
- xattr_stream_name_buf = kmalloc(*xattr_stream_name_size + type_len,
- GFP_KERNEL);
- if (!xattr_stream_name_buf)
+ buf = kasprintf(GFP_KERNEL, "%s%s%s",
+ XATTR_NAME_STREAM, stream_name, type);
+ if (!buf)
return -ENOMEM;
- memcpy(xattr_stream_name_buf, XATTR_NAME_STREAM, XATTR_NAME_STREAM_LEN);
-
- if (stream_name_size) {
- memcpy(&xattr_stream_name_buf[XATTR_NAME_STREAM_LEN],
- stream_name, stream_name_size);
- }
- memcpy(&xattr_stream_name_buf[*xattr_stream_name_size - 1], type, type_len);
- *xattr_stream_name_size += type_len;
-
- xattr_stream_name_buf[*xattr_stream_name_size - 1] = '\0';
- *xattr_stream_name = xattr_stream_name_buf;
+ *xattr_stream_name = buf;
+ *xattr_stream_name_size = strlen(buf) + 1;
return 0;
}