From: Namjae Jeon namjae.jeon@samsung.com
mainline inclusion from mainline-5.15-rc1 commit 20ea7fd2ac7513c90b5d0675360298ca6722593d category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I60T7G CVE: NA
Reference: https://git.kernel.org/torvalds/linux/c/20ea7fd2ac75
-------------------------------
Just use kmalloc() for small allocations.
Signed-off-by: Namjae Jeon namjae.jeon@samsung.com Signed-off-by: Steve French stfrench@microsoft.com Signed-off-by: Jason Yan yanaijie@huawei.com Signed-off-by: Zhong Jinghua zhongjinghua@huawei.com --- fs/cifsd/buffer_pool.c | 2 +- fs/cifsd/mgmt/share_config.c | 4 ++-- fs/cifsd/mgmt/user_config.c | 4 ++-- fs/cifsd/mgmt/user_session.c | 4 ++-- fs/cifsd/oplock.c | 2 +- fs/cifsd/smb2pdu.c | 4 ++-- fs/cifsd/transport_tcp.c | 2 +- fs/cifsd/vfs_cache.c | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/fs/cifsd/buffer_pool.c b/fs/cifsd/buffer_pool.c index 864fea547c68..91c04879e931 100644 --- a/fs/cifsd/buffer_pool.c +++ b/fs/cifsd/buffer_pool.c @@ -63,7 +63,7 @@ static int register_wm_size_class(size_t sz) { struct wm_list *l, *nl;
- nl = kvmalloc(sizeof(struct wm_list), GFP_KERNEL); + nl = kmalloc(sizeof(struct wm_list), GFP_KERNEL); if (!nl) return -ENOMEM;
diff --git a/fs/cifsd/mgmt/share_config.c b/fs/cifsd/mgmt/share_config.c index 9bc7f7555ee2..db780febd692 100644 --- a/fs/cifsd/mgmt/share_config.c +++ b/fs/cifsd/mgmt/share_config.c @@ -92,7 +92,7 @@ static int parse_veto_list(struct ksmbd_share_config *share, while (veto_list_sz > 0) { struct ksmbd_veto_pattern *p;
- p = ksmbd_alloc(sizeof(struct ksmbd_veto_pattern)); + p = kzalloc(sizeof(struct ksmbd_veto_pattern), GFP_KERNEL); if (!p) return -ENOMEM;
@@ -129,7 +129,7 @@ static struct ksmbd_share_config *share_config_request(char *name) if (resp->flags == KSMBD_SHARE_FLAG_INVALID) goto out;
- share = ksmbd_alloc(sizeof(struct ksmbd_share_config)); + share = kzalloc(sizeof(struct ksmbd_share_config), GFP_KERNEL); if (!share) goto out;
diff --git a/fs/cifsd/mgmt/user_config.c b/fs/cifsd/mgmt/user_config.c index a1a454bfb57b..f0c2f8994a6b 100644 --- a/fs/cifsd/mgmt/user_config.c +++ b/fs/cifsd/mgmt/user_config.c @@ -31,7 +31,7 @@ struct ksmbd_user *ksmbd_alloc_user(struct ksmbd_login_response *resp) { struct ksmbd_user *user = NULL;
- user = ksmbd_alloc(sizeof(struct ksmbd_user)); + user = kmalloc(sizeof(struct ksmbd_user), GFP_KERNEL); if (!user) return NULL;
@@ -40,7 +40,7 @@ struct ksmbd_user *ksmbd_alloc_user(struct ksmbd_login_response *resp) user->gid = resp->gid; user->uid = resp->uid; user->passkey_sz = resp->hash_sz; - user->passkey = ksmbd_alloc(resp->hash_sz); + user->passkey = kmalloc(resp->hash_sz, GFP_KERNEL); if (user->passkey) memcpy(user->passkey, resp->hash, resp->hash_sz);
diff --git a/fs/cifsd/mgmt/user_session.c b/fs/cifsd/mgmt/user_session.c index 1b71a20dacdb..5a2113bf18ef 100644 --- a/fs/cifsd/mgmt/user_session.c +++ b/fs/cifsd/mgmt/user_session.c @@ -101,7 +101,7 @@ int ksmbd_session_rpc_open(struct ksmbd_session *sess, char *rpc_name) if (!method) return -EINVAL;
- entry = ksmbd_alloc(sizeof(struct ksmbd_session_rpc)); + entry = kzalloc(sizeof(struct ksmbd_session_rpc), GFP_KERNEL); if (!entry) return -EINVAL;
@@ -266,7 +266,7 @@ static struct ksmbd_session *__session_create(int protocol) struct ksmbd_session *sess; int ret;
- sess = ksmbd_alloc(sizeof(struct ksmbd_session)); + sess = kzalloc(sizeof(struct ksmbd_session), GFP_KERNEL); if (!sess) return NULL;
diff --git a/fs/cifsd/oplock.c b/fs/cifsd/oplock.c index 25823bb7d086..d76aa47e19e4 100644 --- a/fs/cifsd/oplock.c +++ b/fs/cifsd/oplock.c @@ -593,7 +593,7 @@ static int oplock_break_pending(struct oplock_info *opinfo, int req_op_level)
static inline int allocate_oplock_break_buf(struct ksmbd_work *work) { - work->response_buf = ksmbd_alloc_response(MAX_CIFS_SMALL_BUFFER_SIZE); + work->response_buf = kzalloc(MAX_CIFS_SMALL_BUFFER_SIZE, GFP_KERNEL); if (!work->response_buf) return -ENOMEM; work->response_sz = MAX_CIFS_SMALL_BUFFER_SIZE; diff --git a/fs/cifsd/smb2pdu.c b/fs/cifsd/smb2pdu.c index 460d5ba275bf..a1aa42b52597 100644 --- a/fs/cifsd/smb2pdu.c +++ b/fs/cifsd/smb2pdu.c @@ -1174,7 +1174,7 @@ static int alloc_preauth_hash(struct ksmbd_session *sess, if (sess->Preauth_HashValue) return 0;
- sess->Preauth_HashValue = ksmbd_alloc(PREAUTH_HASHVALUE_SIZE); + sess->Preauth_HashValue = kmalloc(PREAUTH_HASHVALUE_SIZE, GFP_KERNEL); if (!sess->Preauth_HashValue) return -ENOMEM;
@@ -8345,7 +8345,7 @@ int smb3_encrypt_resp(struct ksmbd_work *work) if (ARRAY_SIZE(iov) < rq_nvec) return -ENOMEM;
- tr_hdr = ksmbd_alloc_response(sizeof(struct smb2_transform_hdr)); + tr_hdr = kzalloc(sizeof(struct smb2_transform_hdr), GFP_KERNEL); if (!tr_hdr) return rc;
diff --git a/fs/cifsd/transport_tcp.c b/fs/cifsd/transport_tcp.c index 359401227d93..5dd8641f66ba 100644 --- a/fs/cifsd/transport_tcp.c +++ b/fs/cifsd/transport_tcp.c @@ -569,7 +569,7 @@ static struct interface *alloc_iface(char *ifname) if (!ifname) return NULL;
- iface = ksmbd_alloc(sizeof(struct interface)); + iface = kzalloc(sizeof(struct interface), GFP_KERNEL); if (!iface) { kfree(ifname); return NULL; diff --git a/fs/cifsd/vfs_cache.c b/fs/cifsd/vfs_cache.c index 34e045f27230..2b38628e1cb8 100644 --- a/fs/cifsd/vfs_cache.c +++ b/fs/cifsd/vfs_cache.c @@ -830,7 +830,7 @@ int ksmbd_file_table_flush(struct ksmbd_work *work)
int ksmbd_init_file_table(struct ksmbd_file_table *ft) { - ft->idr = ksmbd_alloc(sizeof(struct idr)); + ft->idr = kzalloc(sizeof(struct idr), GFP_KERNEL); if (!ft->idr) return -ENOMEM;