diff options
Diffstat (limited to 'fs/smb')
39 files changed, 119 insertions, 127 deletions
diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c index 2a6b8ce80be2..94574dab56f6 100644 --- a/fs/smb/client/cached_dir.c +++ b/fs/smb/client/cached_dir.c @@ -556,7 +556,7 @@ void close_all_cached_dirs(struct cifs_sb_info *cifs_sb) continue; spin_lock(&cfids->cfid_list_lock); list_for_each_entry(cfid, &cfids->entries, entry) { - tmp_list = kmalloc(sizeof(*tmp_list), GFP_ATOMIC); + tmp_list = kmalloc_obj(*tmp_list, GFP_ATOMIC); if (tmp_list == NULL) { /* * If the malloc() fails, we won't drop all @@ -698,7 +698,7 @@ static struct cached_fid *init_cached_dir(const char *path) { struct cached_fid *cfid; - cfid = kzalloc(sizeof(*cfid), GFP_ATOMIC); + cfid = kzalloc_obj(*cfid, GFP_ATOMIC); if (!cfid) return NULL; cfid->path = kstrdup(path, GFP_ATOMIC); @@ -813,7 +813,7 @@ struct cached_fids *init_cached_dirs(void) { struct cached_fids *cfids; - cfids = kzalloc(sizeof(*cfids), GFP_KERNEL); + cfids = kzalloc_obj(*cfids, GFP_KERNEL); if (!cfids) return NULL; spin_lock_init(&cfids->cfid_list_lock); diff --git a/fs/smb/client/cifs_swn.c b/fs/smb/client/cifs_swn.c index 68a1f87c446d..9753a432d099 100644 --- a/fs/smb/client/cifs_swn.c +++ b/fs/smb/client/cifs_swn.c @@ -315,7 +315,7 @@ static struct cifs_swn_reg *cifs_get_swn_reg(struct cifs_tcon *tcon) goto unlock; } - reg = kmalloc(sizeof(struct cifs_swn_reg), GFP_ATOMIC); + reg = kmalloc_obj(struct cifs_swn_reg, GFP_ATOMIC); if (reg == NULL) { ret = -ENOMEM; goto fail_unlock; diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c index f03eda46f452..85ffb8cfe320 100644 --- a/fs/smb/client/cifsacl.c +++ b/fs/smb/client/cifsacl.c @@ -805,8 +805,7 @@ static void parse_dacl(struct smb_acl *pdacl, char *end_of_acl, offsetof(struct smb_sid, sub_auth) + sizeof(__le16))) return; - ppace = kmalloc_array(num_aces, sizeof(struct smb_ace *), - GFP_KERNEL); + ppace = kmalloc_objs(struct smb_ace *, num_aces, GFP_KERNEL); if (!ppace) return; @@ -1332,8 +1331,7 @@ static int build_sec_desc(struct smb_ntsd *pntsd, struct smb_ntsd *pnntsd, if (uid_valid(uid)) { /* chown */ uid_t id; - nowner_sid_ptr = kzalloc(sizeof(struct smb_sid), - GFP_KERNEL); + nowner_sid_ptr = kzalloc_obj(struct smb_sid, GFP_KERNEL); if (!nowner_sid_ptr) { rc = -ENOMEM; goto chown_chgrp_exit; @@ -1361,8 +1359,7 @@ static int build_sec_desc(struct smb_ntsd *pntsd, struct smb_ntsd *pnntsd, } if (gid_valid(gid)) { /* chgrp */ gid_t id; - ngroup_sid_ptr = kzalloc(sizeof(struct smb_sid), - GFP_KERNEL); + ngroup_sid_ptr = kzalloc_obj(struct smb_sid, GFP_KERNEL); if (!ngroup_sid_ptr) { rc = -ENOMEM; goto chown_chgrp_exit; diff --git a/fs/smb/client/cifsencrypt.c b/fs/smb/client/cifsencrypt.c index 50b7ec39053c..b717b348e98e 100644 --- a/fs/smb/client/cifsencrypt.c +++ b/fs/smb/client/cifsencrypt.c @@ -500,7 +500,7 @@ calc_seckey(struct cifs_ses *ses) get_random_bytes(sec_key, CIFS_SESS_KEY_SIZE); - ctx_arc4 = kmalloc(sizeof(*ctx_arc4), GFP_KERNEL); + ctx_arc4 = kmalloc_obj(*ctx_arc4, GFP_KERNEL); if (!ctx_arc4) { cifs_dbg(VFS, "Could not allocate arc4 context\n"); return -ENOMEM; diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c index afda1d7c1ee1..85a53cd77f9e 100644 --- a/fs/smb/client/cifsfs.c +++ b/fs/smb/client/cifsfs.c @@ -1016,11 +1016,11 @@ cifs_smb3_do_mount(struct file_system_type *fs_type, } else { cifs_info("Attempting to mount %s\n", old_ctx->source); } - cifs_sb = kzalloc(sizeof(*cifs_sb), GFP_KERNEL); + cifs_sb = kzalloc_obj(*cifs_sb, GFP_KERNEL); if (!cifs_sb) return ERR_PTR(-ENOMEM); - cifs_sb->ctx = kzalloc(sizeof(struct smb3_fs_context), GFP_KERNEL); + cifs_sb->ctx = kzalloc_obj(struct smb3_fs_context, GFP_KERNEL); if (!cifs_sb->ctx) { root = ERR_PTR(-ENOMEM); goto out; diff --git a/fs/smb/client/compress.c b/fs/smb/client/compress.c index e0c44b46080e..ae536aa63ef1 100644 --- a/fs/smb/client/compress.c +++ b/fs/smb/client/compress.c @@ -229,7 +229,7 @@ static bool is_compressible(const struct iov_iter *data) if (has_repeated_data(sample, len)) goto out; - bkt = kcalloc(bkt_size, sizeof(*bkt), GFP_KERNEL); + bkt = kzalloc_objs(*bkt, bkt_size, GFP_KERNEL); if (!bkt) { WARN_ON_ONCE(1); ret = false; diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c index 1b479561cbf9..c7ed2ffb66ee 100644 --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -1755,7 +1755,7 @@ cifs_get_tcp_session(struct smb3_fs_context *ctx, if (tcp_ses) return tcp_ses; - tcp_ses = kzalloc(sizeof(struct TCP_Server_Info), GFP_KERNEL); + tcp_ses = kzalloc_obj(struct TCP_Server_Info, GFP_KERNEL); if (!tcp_ses) { rc = -ENOMEM; goto out_err; @@ -3674,7 +3674,7 @@ static int mount_setup_tlink(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses, struct tcon_link *tlink; /* hang the tcon off of the superblock */ - tlink = kzalloc(sizeof(*tlink), GFP_KERNEL); + tlink = kzalloc_obj(*tlink, GFP_KERNEL); if (tlink == NULL) return -ENOMEM; @@ -3798,7 +3798,7 @@ mchan_mount_alloc(struct cifs_ses *ses) { struct mchan_mount *mchan_mount; - mchan_mount = kzalloc(sizeof(*mchan_mount), GFP_KERNEL); + mchan_mount = kzalloc_obj(*mchan_mount, GFP_KERNEL); if (!mchan_mount) return ERR_PTR(-ENOMEM); @@ -4193,7 +4193,7 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, kuid_t fsuid) struct smb3_fs_context *ctx; char *origin_fullpath = NULL; - ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); + ctx = kzalloc_obj(*ctx, GFP_KERNEL); if (ctx == NULL) return ERR_PTR(-ENOMEM); @@ -4367,7 +4367,7 @@ cifs_sb_tlink(struct cifs_sb_info *cifs_sb) spin_unlock(&cifs_sb->tlink_tree_lock); if (tlink == NULL) { - newtlink = kzalloc(sizeof(*tlink), GFP_KERNEL); + newtlink = kzalloc_obj(*tlink, GFP_KERNEL); if (newtlink == NULL) return ERR_PTR(-ENOMEM); newtlink->tl_uid = fsuid; diff --git a/fs/smb/client/dfs.h b/fs/smb/client/dfs.h index 6b5b5ca0f55c..0401c55517b8 100644 --- a/fs/smb/client/dfs.h +++ b/fs/smb/client/dfs.h @@ -46,7 +46,7 @@ static inline struct dfs_ref_walk *ref_walk_alloc(void) { struct dfs_ref_walk *rw; - rw = kmalloc(sizeof(*rw), GFP_KERNEL); + rw = kmalloc_obj(*rw, GFP_KERNEL); if (!rw) return ERR_PTR(-ENOMEM); return rw; diff --git a/fs/smb/client/dfs_cache.c b/fs/smb/client/dfs_cache.c index f2ad0ccd08a7..983132735d72 100644 --- a/fs/smb/client/dfs_cache.c +++ b/fs/smb/client/dfs_cache.c @@ -363,7 +363,7 @@ static struct cache_dfs_tgt *alloc_target(const char *name, int path_consumed) { struct cache_dfs_tgt *t; - t = kmalloc(sizeof(*t), GFP_ATOMIC); + t = kmalloc_obj(*t, GFP_ATOMIC); if (!t) return ERR_PTR(-ENOMEM); t->name = kstrdup(name, GFP_ATOMIC); @@ -796,7 +796,7 @@ static int get_targets(struct cache_entry *ce, struct dfs_cache_tgt_list *tl) INIT_LIST_HEAD(head); list_for_each_entry(t, &ce->tlist, list) { - it = kzalloc(sizeof(*it), GFP_ATOMIC); + it = kzalloc_obj(*it, GFP_ATOMIC); if (!it) { rc = -ENOMEM; goto err_free_it; diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c index 88273f82812b..43b5b48f5a67 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -489,7 +489,7 @@ int cifs_posix_open(const char *full_path, struct inode **pinode, cifs_dbg(FYI, "posix open %s\n", full_path); - presp_data = kzalloc(sizeof(FILE_UNIX_BASIC_INFO), GFP_KERNEL); + presp_data = kzalloc_obj(FILE_UNIX_BASIC_INFO, GFP_KERNEL); if (presp_data == NULL) return -ENOMEM; @@ -673,11 +673,11 @@ struct cifsFileInfo *cifs_new_fileinfo(struct cifs_fid *fid, struct file *file, struct cifs_tcon *tcon = tlink_tcon(tlink); struct TCP_Server_Info *server = tcon->ses->server; - cfile = kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL); + cfile = kzalloc_obj(struct cifsFileInfo, GFP_KERNEL); if (cfile == NULL) return cfile; - fdlocks = kzalloc(sizeof(struct cifs_fid_locks), GFP_KERNEL); + fdlocks = kzalloc_obj(struct cifs_fid_locks, GFP_KERNEL); if (!fdlocks) { kfree(cfile); return NULL; @@ -1458,7 +1458,7 @@ int cifs_close(struct inode *inode, struct file *file) if (file->private_data != NULL) { cfile = file->private_data; file->private_data = NULL; - dclose = kmalloc(sizeof(struct cifs_deferred_close), GFP_KERNEL); + dclose = kmalloc_obj(struct cifs_deferred_close, GFP_KERNEL); if ((cfile->status_file_deleted == false) && (smb2_can_defer_close(inode, dclose))) { if (test_and_clear_bit(NETFS_ICTX_MODIFIED_ATTR, &cinode->netfs.flags)) { @@ -1582,7 +1582,7 @@ static struct cifsLockInfo * cifs_lock_init(__u64 offset, __u64 length, __u8 type, __u16 flags) { struct cifsLockInfo *lock = - kmalloc(sizeof(struct cifsLockInfo), GFP_KERNEL); + kmalloc_obj(struct cifsLockInfo, GFP_KERNEL); if (!lock) return lock; lock->offset = offset; @@ -1853,7 +1853,7 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile) PAGE_SIZE); max_num = (max_buf - sizeof(struct smb_hdr)) / sizeof(LOCKING_ANDX_RANGE); - buf = kcalloc(max_num, sizeof(LOCKING_ANDX_RANGE), GFP_KERNEL); + buf = kzalloc_objs(LOCKING_ANDX_RANGE, max_num, GFP_KERNEL); if (!buf) { free_xid(xid); return -ENOMEM; @@ -1945,7 +1945,7 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile) * protects locking operations of this inode. */ for (i = 0; i < count; i++) { - lck = kmalloc(sizeof(struct lock_to_push), GFP_KERNEL); + lck = kmalloc_obj(struct lock_to_push, GFP_KERNEL); if (!lck) { rc = -ENOMEM; goto err_out; @@ -2229,7 +2229,7 @@ cifs_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock, PAGE_SIZE); max_num = (max_buf - sizeof(struct smb_hdr)) / sizeof(LOCKING_ANDX_RANGE); - buf = kcalloc(max_num, sizeof(LOCKING_ANDX_RANGE), GFP_KERNEL); + buf = kzalloc_objs(LOCKING_ANDX_RANGE, max_num, GFP_KERNEL); if (!buf) return -ENOMEM; diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c index 412c5b534791..4810f926dccb 100644 --- a/fs/smb/client/fs_context.c +++ b/fs/smb/client/fs_context.c @@ -1924,7 +1924,7 @@ int smb3_init_fs_context(struct fs_context *fc) char *nodename = utsname()->nodename; int i; - ctx = kzalloc(sizeof(struct smb3_fs_context), GFP_KERNEL); + ctx = kzalloc_obj(struct smb3_fs_context, GFP_KERNEL); if (unlikely(!ctx)) return -ENOMEM; diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c index c23c057162e6..d40f39f9547c 100644 --- a/fs/smb/client/inode.c +++ b/fs/smb/client/inode.c @@ -1841,7 +1841,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, /* set ATTR_HIDDEN and clear ATTR_READONLY, but only if needed */ if (dosattr != origattr) { - info_buf = kzalloc(sizeof(*info_buf), GFP_KERNEL); + info_buf = kzalloc_obj(*info_buf, GFP_KERNEL); if (info_buf == NULL) { rc = -ENOMEM; goto out_close; @@ -2041,7 +2041,7 @@ psx_del_no_retry: } } } else if ((rc == -EACCES) && (dosattr == 0) && inode) { - attrs = kzalloc(sizeof(*attrs), GFP_KERNEL); + attrs = kzalloc_obj(*attrs, GFP_KERNEL); if (attrs == NULL) { rc = -ENOMEM; goto out_reval; @@ -2197,7 +2197,7 @@ cifs_posix_mkdir(struct inode *inode, struct dentry *dentry, umode_t mode, struct inode *newinode = NULL; struct cifs_fattr fattr; - info = kzalloc(sizeof(FILE_UNIX_BASIC_INFO), GFP_KERNEL); + info = kzalloc_obj(FILE_UNIX_BASIC_INFO, GFP_KERNEL); if (info == NULL) { rc = -ENOMEM; goto posix_mkdir_out; @@ -2585,8 +2585,7 @@ cifs_rename2(struct mnt_idmap *idmap, struct inode *source_dir, * with unix extensions enabled. */ info_buf_source = - kmalloc_array(2, sizeof(FILE_UNIX_BASIC_INFO), - GFP_KERNEL); + kmalloc_objs(FILE_UNIX_BASIC_INFO, 2, GFP_KERNEL); if (info_buf_source == NULL) { rc = -ENOMEM; goto cifs_rename_exit; @@ -3167,7 +3166,7 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs) if (attrs->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID)) attrs->ia_valid &= ~ATTR_MODE; - args = kmalloc(sizeof(*args), GFP_KERNEL); + args = kmalloc_obj(*args, GFP_KERNEL); if (args == NULL) { rc = -ENOMEM; goto out; diff --git a/fs/smb/client/ioctl.c b/fs/smb/client/ioctl.c index a4aa063cf5ea..6d24184c8735 100644 --- a/fs/smb/client/ioctl.c +++ b/fs/smb/client/ioctl.c @@ -133,7 +133,7 @@ static long smb_mnt_get_fsinfo(unsigned int xid, struct cifs_tcon *tcon, int rc = 0; struct smb_mnt_fs_info *fsinf; - fsinf = kzalloc(sizeof(struct smb_mnt_fs_info), GFP_KERNEL); + fsinf = kzalloc_obj(struct smb_mnt_fs_info, GFP_KERNEL); if (fsinf == NULL) return -ENOMEM; diff --git a/fs/smb/client/misc.c b/fs/smb/client/misc.c index 1773e3b471aa..290d0a0bea53 100644 --- a/fs/smb/client/misc.c +++ b/fs/smb/client/misc.c @@ -67,7 +67,7 @@ sesInfoAlloc(void) { struct cifs_ses *ret_buf; - ret_buf = kzalloc(sizeof(struct cifs_ses), GFP_KERNEL); + ret_buf = kzalloc_obj(struct cifs_ses, GFP_KERNEL); if (ret_buf) { atomic_inc(&sesInfoAllocCount); spin_lock_init(&ret_buf->ses_lock); @@ -118,7 +118,7 @@ tcon_info_alloc(bool dir_leases_enabled, enum smb3_tcon_ref_trace trace) struct cifs_tcon *ret_buf; static atomic_t tcon_debug_id; - ret_buf = kzalloc(sizeof(*ret_buf), GFP_KERNEL); + ret_buf = kzalloc_obj(*ret_buf, GFP_KERNEL); if (!ret_buf) return NULL; @@ -499,7 +499,8 @@ cifs_close_deferred_file(struct cifsInodeInfo *cifs_inode) cifs_del_deferred_close(cfile); spin_unlock(&cifs_inode->deferred_lock); - tmp_list = kmalloc(sizeof(struct file_list), GFP_ATOMIC); + tmp_list = kmalloc_obj(struct file_list, + GFP_ATOMIC); if (tmp_list == NULL) break; tmp_list->cfile = cfile; @@ -531,7 +532,8 @@ cifs_close_all_deferred_files(struct cifs_tcon *tcon) cifs_del_deferred_close(cfile); spin_unlock(&CIFS_I(d_inode(cfile->dentry))->deferred_lock); - tmp_list = kmalloc(sizeof(struct file_list), GFP_ATOMIC); + tmp_list = kmalloc_obj(struct file_list, + GFP_ATOMIC); if (tmp_list == NULL) break; tmp_list->cfile = cfile; @@ -564,7 +566,7 @@ void cifs_close_deferred_file_under_dentry(struct cifs_tcon *tcon, cifs_del_deferred_close(cfile); spin_unlock(&CIFS_I(d_inode(cfile->dentry))->deferred_lock); - tmp_list = kmalloc(sizeof(struct file_list), GFP_ATOMIC); + tmp_list = kmalloc_obj(struct file_list, GFP_ATOMIC); if (tmp_list == NULL) break; tmp_list->cfile = cfile; @@ -671,8 +673,8 @@ parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size, cifs_dbg(FYI, "num_referrals: %d dfs flags: 0x%x ...\n", *num_of_nodes, le32_to_cpu(rsp->DFSFlags)); - *target_nodes = kcalloc(*num_of_nodes, sizeof(struct dfs_info3_param), - GFP_KERNEL); + *target_nodes = kzalloc_objs(struct dfs_info3_param, *num_of_nodes, + GFP_KERNEL); if (*target_nodes == NULL) { rc = -ENOMEM; goto parse_DFS_referrals_exit; diff --git a/fs/smb/client/readdir.c b/fs/smb/client/readdir.c index 67a8555efa1e..53e17fb2b6ee 100644 --- a/fs/smb/client/readdir.c +++ b/fs/smb/client/readdir.c @@ -358,7 +358,7 @@ _initiate_cifs_search(const unsigned int xid, struct file *file, if (IS_ERR(tlink)) return PTR_ERR(tlink); - cifsFile = kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL); + cifsFile = kzalloc_obj(struct cifsFileInfo, GFP_KERNEL); if (cifsFile == NULL) { rc = -ENOMEM; goto error_exit; @@ -888,7 +888,7 @@ static bool add_cached_dirent(struct cached_dirents *cde, cde->is_failed = 1; return false; } - de = kzalloc(sizeof(*de), GFP_ATOMIC); + de = kzalloc_obj(*de, GFP_ATOMIC); if (de == NULL) { cde->is_failed = 1; return false; diff --git a/fs/smb/client/sess.c b/fs/smb/client/sess.c index d523540565ef..e32f9e185499 100644 --- a/fs/smb/client/sess.c +++ b/fs/smb/client/sess.c @@ -510,7 +510,7 @@ cifs_ses_add_channel(struct cifs_ses *ses, * the session and server without caring about memory * management. */ - ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); + ctx = kzalloc_obj(*ctx, GFP_KERNEL); if (!ctx) { rc = -ENOMEM; goto out_free_xid; diff --git a/fs/smb/client/smb1ops.c b/fs/smb/client/smb1ops.c index 970aeffe936e..689e052c2809 100644 --- a/fs/smb/client/smb1ops.c +++ b/fs/smb/client/smb1ops.c @@ -506,7 +506,7 @@ cifs_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon, int rc; FILE_ALL_INFO *file_info; - file_info = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL); + file_info = kmalloc_obj(FILE_ALL_INFO, GFP_KERNEL); if (file_info == NULL) return -ENOMEM; diff --git a/fs/smb/client/smb1session.c b/fs/smb/client/smb1session.c index 1cf6bd640fde..f5ef07d24b5f 100644 --- a/fs/smb/client/smb1session.c +++ b/fs/smb/client/smb1session.c @@ -725,7 +725,7 @@ sess_auth_rawntlmssp_negotiate(struct sess_data *sess_data) * if memory allocation is successful, caller of this function * frees it. */ - ses->ntlmssp = kmalloc(sizeof(struct ntlmssp_auth), GFP_KERNEL); + ses->ntlmssp = kmalloc_obj(struct ntlmssp_auth, GFP_KERNEL); if (!ses->ntlmssp) { rc = -ENOMEM; goto out; @@ -969,7 +969,7 @@ int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses, return -EINVAL; } - sess_data = kzalloc(sizeof(struct sess_data), GFP_KERNEL); + sess_data = kzalloc_obj(struct sess_data, GFP_KERNEL); if (!sess_data) return -ENOMEM; diff --git a/fs/smb/client/smb2file.c b/fs/smb/client/smb2file.c index 476c53b3711f..6dba874156aa 100644 --- a/fs/smb/client/smb2file.c +++ b/fs/smb/client/smb2file.c @@ -281,7 +281,7 @@ smb2_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock, BUILD_BUG_ON(sizeof(struct smb2_lock_element) > PAGE_SIZE); max_buf = min_t(unsigned int, max_buf, PAGE_SIZE); max_num = max_buf / sizeof(struct smb2_lock_element); - buf = kcalloc(max_num, sizeof(struct smb2_lock_element), GFP_KERNEL); + buf = kzalloc_objs(struct smb2_lock_element, max_num, GFP_KERNEL); if (!buf) return -ENOMEM; @@ -424,7 +424,7 @@ smb2_push_mandatory_locks(struct cifsFileInfo *cfile) BUILD_BUG_ON(sizeof(struct smb2_lock_element) > PAGE_SIZE); max_buf = min_t(unsigned int, max_buf, PAGE_SIZE); max_num = max_buf / sizeof(struct smb2_lock_element); - buf = kcalloc(max_num, sizeof(struct smb2_lock_element), GFP_KERNEL); + buf = kzalloc_objs(struct smb2_lock_element, max_num, GFP_KERNEL); if (!buf) { free_xid(xid); return -ENOMEM; diff --git a/fs/smb/client/smb2inode.c b/fs/smb/client/smb2inode.c index 8a30088fed15..195a38fd61e8 100644 --- a/fs/smb/client/smb2inode.c +++ b/fs/smb/client/smb2inode.c @@ -209,7 +209,7 @@ replay_again: num_rqst = 0; server = cifs_pick_channel(ses); - vars = kzalloc(sizeof(*vars), GFP_ATOMIC); + vars = kzalloc_obj(*vars, GFP_ATOMIC); if (vars == NULL) { rc = -ENOMEM; goto out; diff --git a/fs/smb/client/smb2misc.c b/fs/smb/client/smb2misc.c index d1ae839e4863..efba7cb9fb70 100644 --- a/fs/smb/client/smb2misc.c +++ b/fs/smb/client/smb2misc.c @@ -526,7 +526,7 @@ smb2_queue_pending_open_break(struct tcon_link *tlink, __u8 *lease_key, { struct smb2_lease_break_work *lw; - lw = kmalloc(sizeof(struct smb2_lease_break_work), GFP_KERNEL); + lw = kmalloc_obj(struct smb2_lease_break_work, GFP_KERNEL); if (!lw) { cifs_put_tlink(tlink); return; @@ -798,7 +798,7 @@ __smb2_handle_cancelled_cmd(struct cifs_tcon *tcon, __u16 cmd, __u64 mid, { struct close_cancelled_open *cancelled; - cancelled = kzalloc(sizeof(*cancelled), GFP_KERNEL); + cancelled = kzalloc_obj(*cancelled, GFP_KERNEL); if (!cancelled) return -ENOMEM; diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index 7370d7a18cd0..071df7465a8b 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -731,8 +731,7 @@ parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf, spin_unlock(&ses->iface_lock); /* no match. insert the entry in the list */ - info = kmalloc(sizeof(struct cifs_server_iface), - GFP_KERNEL); + info = kmalloc_obj(struct cifs_server_iface, GFP_KERNEL); if (!info) { rc = -ENOMEM; goto out; @@ -1202,7 +1201,7 @@ replay_again: ea = NULL; resp_buftype[0] = resp_buftype[1] = resp_buftype[2] = CIFS_NO_BUFFER; - vars = kzalloc(sizeof(*vars), GFP_KERNEL); + vars = kzalloc_obj(*vars, GFP_KERNEL); if (!vars) { rc = -ENOMEM; goto out_free_path; @@ -1594,7 +1593,7 @@ replay_again: oplock = SMB2_OPLOCK_LEVEL_NONE; server = cifs_pick_channel(ses); - vars = kzalloc(sizeof(*vars), GFP_ATOMIC); + vars = kzalloc_obj(*vars, GFP_ATOMIC); if (vars == NULL) return -ENOMEM; rqst = &vars->rqst[0]; @@ -1889,7 +1888,7 @@ retry: goto out; } - cc_req = kzalloc(struct_size(cc_req, Chunks, chunk_count), GFP_KERNEL); + cc_req = kzalloc_flex(*cc_req, Chunks, chunk_count, GFP_KERNEL); if (!cc_req) { rc = -ENOMEM; goto out; @@ -2850,7 +2849,7 @@ replay_again: flags |= CIFS_TRANSFORM_REQ; resp_buftype[0] = resp_buftype[1] = resp_buftype[2] = CIFS_NO_BUFFER; - vars = kzalloc(sizeof(*vars), GFP_KERNEL); + vars = kzalloc_obj(*vars, GFP_KERNEL); if (!vars) { rc = -ENOMEM; goto out_free_path; @@ -4221,7 +4220,7 @@ smb2_create_lease_buf(u8 *lease_key, u8 oplock, u8 *parent_lease_key, __le32 fla { struct create_lease *buf; - buf = kzalloc(sizeof(struct create_lease), GFP_KERNEL); + buf = kzalloc_obj(struct create_lease, GFP_KERNEL); if (!buf) return NULL; @@ -4247,7 +4246,7 @@ smb3_create_lease_buf(u8 *lease_key, u8 oplock, u8 *parent_lease_key, __le32 fla { struct create_lease_v2 *buf; - buf = kzalloc(sizeof(struct create_lease_v2), GFP_KERNEL); + buf = kzalloc_obj(struct create_lease_v2, GFP_KERNEL); if (!buf) return NULL; @@ -4931,7 +4930,7 @@ receive_encrypted_read(struct TCP_Server_Info *server, struct mid_q_entry **mid, int rc; struct smb2_decrypt_work *dw; - dw = kzalloc(sizeof(struct smb2_decrypt_work), GFP_KERNEL); + dw = kzalloc_obj(struct smb2_decrypt_work, GFP_KERNEL); if (!dw) return -ENOMEM; INIT_WORK(&dw->decrypt, smb2_decrypt_offload); diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c index 7f3edf42b9c3..0ebfdfebc5e9 100644 --- a/fs/smb/client/smb2pdu.c +++ b/fs/smb/client/smb2pdu.c @@ -1009,8 +1009,7 @@ create_posix_buf(umode_t mode) { struct create_posix *buf; - buf = kzalloc(sizeof(struct create_posix), - GFP_KERNEL); + buf = kzalloc_obj(struct create_posix, GFP_KERNEL); if (!buf) return NULL; @@ -1359,7 +1358,7 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) if (tcon->ses->session_flags & SMB2_SESSION_FLAG_IS_NULL) cifs_tcon_dbg(VFS, "Unexpected null user (anonymous) auth flag sent by server\n"); - pneg_inbuf = kmalloc(sizeof(*pneg_inbuf), GFP_NOFS); + pneg_inbuf = kmalloc_obj(*pneg_inbuf, GFP_NOFS); if (!pneg_inbuf) return -ENOMEM; @@ -1786,7 +1785,7 @@ SMB2_sess_auth_rawntlmssp_negotiate(struct SMB2_sess_data *sess_data) * If memory allocation is successful, caller of this function * frees it. */ - ses->ntlmssp = kmalloc(sizeof(struct ntlmssp_auth), GFP_KERNEL); + ses->ntlmssp = kmalloc_obj(struct ntlmssp_auth, GFP_KERNEL); if (!ses->ntlmssp) { rc = -ENOMEM; goto out_err; @@ -1984,7 +1983,7 @@ SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses, return smb_EIO(smb_eio_trace_null_pointers); } - sess_data = kzalloc(sizeof(struct SMB2_sess_data), GFP_KERNEL); + sess_data = kzalloc_obj(struct SMB2_sess_data, GFP_KERNEL); if (!sess_data) return -ENOMEM; @@ -2298,7 +2297,7 @@ create_durable_buf(void) { create_durable_req_t *buf; - buf = kzalloc(sizeof(create_durable_req_t), GFP_KERNEL); + buf = kzalloc_obj(create_durable_req_t, GFP_KERNEL); if (!buf) return NULL; @@ -2321,7 +2320,7 @@ create_reconnect_durable_buf(struct cifs_fid *fid) { create_durable_req_t *buf; - buf = kzalloc(sizeof(create_durable_req_t), GFP_KERNEL); + buf = kzalloc_obj(create_durable_req_t, GFP_KERNEL); if (!buf) return NULL; @@ -2493,7 +2492,7 @@ create_durable_v2_buf(struct cifs_open_parms *oparms) struct cifs_fid *pfid = oparms->fid; struct create_durable_req_v2 *buf; - buf = kzalloc(sizeof(struct create_durable_req_v2), GFP_KERNEL); + buf = kzalloc_obj(struct create_durable_req_v2, GFP_KERNEL); if (!buf) return NULL; @@ -2534,8 +2533,7 @@ create_reconnect_durable_v2_buf(struct cifs_fid *fid) { struct create_durable_handle_reconnect_v2 *buf; - buf = kzalloc(sizeof(struct create_durable_handle_reconnect_v2), - GFP_KERNEL); + buf = kzalloc_obj(struct create_durable_handle_reconnect_v2, GFP_KERNEL); if (!buf) return NULL; @@ -2626,7 +2624,7 @@ create_twarp_buf(__u64 timewarp) { struct crt_twarp_ctxt *buf; - buf = kzalloc(sizeof(struct crt_twarp_ctxt), GFP_KERNEL); + buf = kzalloc_obj(struct crt_twarp_ctxt, GFP_KERNEL); if (!buf) return NULL; @@ -2793,7 +2791,7 @@ create_query_id_buf(void) { struct crt_query_id_ctxt *buf; - buf = kzalloc(sizeof(struct crt_query_id_ctxt), GFP_KERNEL); + buf = kzalloc_obj(struct crt_query_id_ctxt, GFP_KERNEL); if (!buf) return NULL; @@ -5845,7 +5843,7 @@ replay_again: if (smb3_encryption_required(tcon)) flags |= CIFS_TRANSFORM_REQ; - iov = kmalloc_array(num, sizeof(struct kvec), GFP_KERNEL); + iov = kmalloc_objs(struct kvec, num, GFP_KERNEL); if (!iov) return -ENOMEM; diff --git a/fs/smb/client/smbdirect.c b/fs/smb/client/smbdirect.c index d44847c9d8fc..e2df73c719fd 100644 --- a/fs/smb/client/smbdirect.c +++ b/fs/smb/client/smbdirect.c @@ -2098,7 +2098,7 @@ static struct smbd_connection *_smbd_get_connection( char wq_name[80]; struct workqueue_struct *workqueue; - info = kzalloc(sizeof(struct smbd_connection), GFP_KERNEL); + info = kzalloc_obj(struct smbd_connection, GFP_KERNEL); if (!info) return NULL; sc = &info->socket; @@ -2786,7 +2786,7 @@ static int allocate_mr_list(struct smbdirect_socket *sc) /* Allocate more MRs (2x) than hardware responder_resources */ for (i = 0; i < sp->responder_resources * 2; i++) { - mr = kzalloc(sizeof(*mr), GFP_KERNEL); + mr = kzalloc_obj(*mr, GFP_KERNEL); if (!mr) { ret = -ENOMEM; goto kzalloc_mr_failed; @@ -2805,9 +2805,8 @@ static int allocate_mr_list(struct smbdirect_socket *sc) goto ib_alloc_mr_failed; } - mr->sgt.sgl = kcalloc(sp->max_frmr_depth, - sizeof(struct scatterlist), - GFP_KERNEL); + mr->sgt.sgl = kzalloc_objs(struct scatterlist, + sp->max_frmr_depth, GFP_KERNEL); if (!mr->sgt.sgl) { ret = -ENOMEM; log_rdma_mr(ERR, "failed to allocate sgl\n"); diff --git a/fs/smb/server/auth.c b/fs/smb/server/auth.c index 09af55b71153..580c4d303dc3 100644 --- a/fs/smb/server/auth.c +++ b/fs/smb/server/auth.c @@ -239,7 +239,7 @@ int ksmbd_decode_ntlmssp_auth_blob(struct authenticate_message *authblob, if (sess_key_len > CIFS_KEY_SIZE) return -EINVAL; - ctx_arc4 = kmalloc(sizeof(*ctx_arc4), KSMBD_DEFAULT_GFP); + ctx_arc4 = kmalloc_obj(*ctx_arc4, KSMBD_DEFAULT_GFP); if (!ctx_arc4) return -ENOMEM; @@ -774,7 +774,7 @@ static struct scatterlist *ksmbd_init_sg(struct kvec *iov, unsigned int nvec, if (!nvec) return NULL; - nr_entries = kcalloc(nvec, sizeof(int), KSMBD_DEFAULT_GFP); + nr_entries = kzalloc_objs(int, nvec, KSMBD_DEFAULT_GFP); if (!nr_entries) return NULL; @@ -794,8 +794,7 @@ static struct scatterlist *ksmbd_init_sg(struct kvec *iov, unsigned int nvec, /* Add two entries for transform header and signature */ total_entries += 2; - sg = kmalloc_array(total_entries, sizeof(struct scatterlist), - KSMBD_DEFAULT_GFP); + sg = kmalloc_objs(struct scatterlist, total_entries, KSMBD_DEFAULT_GFP); if (!sg) { kfree(nr_entries); return NULL; diff --git a/fs/smb/server/connection.c b/fs/smb/server/connection.c index e7e3e77006b1..1bb2081c492c 100644 --- a/fs/smb/server/connection.c +++ b/fs/smb/server/connection.c @@ -111,7 +111,7 @@ struct ksmbd_conn *ksmbd_conn_alloc(void) { struct ksmbd_conn *conn; - conn = kzalloc(sizeof(struct ksmbd_conn), KSMBD_DEFAULT_GFP); + conn = kzalloc_obj(struct ksmbd_conn, KSMBD_DEFAULT_GFP); if (!conn) return NULL; diff --git a/fs/smb/server/crypto_ctx.c b/fs/smb/server/crypto_ctx.c index fe29d186baf6..8fd9713b00b7 100644 --- a/fs/smb/server/crypto_ctx.c +++ b/fs/smb/server/crypto_ctx.c @@ -121,7 +121,7 @@ static struct ksmbd_crypto_ctx *ksmbd_find_crypto_ctx(void) ctx_list.avail_ctx++; spin_unlock(&ctx_list.ctx_lock); - ctx = kzalloc(sizeof(struct ksmbd_crypto_ctx), KSMBD_DEFAULT_GFP); + ctx = kzalloc_obj(struct ksmbd_crypto_ctx, KSMBD_DEFAULT_GFP); if (!ctx) { spin_lock(&ctx_list.ctx_lock); ctx_list.avail_ctx--; @@ -226,7 +226,7 @@ int ksmbd_crypto_create(void) init_waitqueue_head(&ctx_list.ctx_wait); ctx_list.avail_ctx = 1; - ctx = kzalloc(sizeof(struct ksmbd_crypto_ctx), KSMBD_DEFAULT_GFP); + ctx = kzalloc_obj(struct ksmbd_crypto_ctx, KSMBD_DEFAULT_GFP); if (!ctx) return -ENOMEM; list_add(&ctx->list, &ctx_list.idle_ctx); diff --git a/fs/smb/server/ksmbd_work.c b/fs/smb/server/ksmbd_work.c index 4a71f46d7020..ab4958dc3eb0 100644 --- a/fs/smb/server/ksmbd_work.c +++ b/fs/smb/server/ksmbd_work.c @@ -28,8 +28,8 @@ struct ksmbd_work *ksmbd_alloc_work_struct(void) INIT_LIST_HEAD(&work->fp_entry); INIT_LIST_HEAD(&work->aux_read_list); work->iov_alloc_cnt = 4; - work->iov = kcalloc(work->iov_alloc_cnt, sizeof(struct kvec), - KSMBD_DEFAULT_GFP); + work->iov = kzalloc_objs(struct kvec, work->iov_alloc_cnt, + KSMBD_DEFAULT_GFP); if (!work->iov) { kmem_cache_free(work_cache, work); work = NULL; @@ -111,7 +111,7 @@ static int __ksmbd_iov_pin_rsp(struct ksmbd_work *work, void *ib, int len, if (aux_size) { need_iov_cnt++; - ar = kmalloc(sizeof(struct aux_read), KSMBD_DEFAULT_GFP); + ar = kmalloc_obj(struct aux_read, KSMBD_DEFAULT_GFP); if (!ar) return -ENOMEM; } diff --git a/fs/smb/server/mgmt/share_config.c b/fs/smb/server/mgmt/share_config.c index c9b1108d6e96..53f44ff4d376 100644 --- a/fs/smb/server/mgmt/share_config.c +++ b/fs/smb/server/mgmt/share_config.c @@ -102,7 +102,7 @@ static int parse_veto_list(struct ksmbd_share_config *share, if (!sz) break; - p = kzalloc(sizeof(struct ksmbd_veto_pattern), KSMBD_DEFAULT_GFP); + p = kzalloc_obj(struct ksmbd_veto_pattern, KSMBD_DEFAULT_GFP); if (!p) return -ENOMEM; @@ -150,7 +150,7 @@ static struct ksmbd_share_config *share_config_request(struct ksmbd_work *work, goto out; } - share = kzalloc(sizeof(struct ksmbd_share_config), KSMBD_DEFAULT_GFP); + share = kzalloc_obj(struct ksmbd_share_config, KSMBD_DEFAULT_GFP); if (!share) goto out; diff --git a/fs/smb/server/mgmt/tree_connect.c b/fs/smb/server/mgmt/tree_connect.c index 57dd47ef688c..a72d7e42a6c2 100644 --- a/fs/smb/server/mgmt/tree_connect.c +++ b/fs/smb/server/mgmt/tree_connect.c @@ -32,8 +32,7 @@ ksmbd_tree_conn_connect(struct ksmbd_work *work, const char *share_name) if (!sc) return status; - tree_conn = kzalloc(sizeof(struct ksmbd_tree_connect), - KSMBD_DEFAULT_GFP); + tree_conn = kzalloc_obj(struct ksmbd_tree_connect, KSMBD_DEFAULT_GFP); if (!tree_conn) { status.ret = -ENOMEM; goto out_error; diff --git a/fs/smb/server/mgmt/user_config.c b/fs/smb/server/mgmt/user_config.c index 3267b86b8c16..a3183fe5c536 100644 --- a/fs/smb/server/mgmt/user_config.c +++ b/fs/smb/server/mgmt/user_config.c @@ -36,7 +36,7 @@ struct ksmbd_user *ksmbd_alloc_user(struct ksmbd_login_response *resp, { struct ksmbd_user *user; - user = kmalloc(sizeof(struct ksmbd_user), KSMBD_DEFAULT_GFP); + user = kmalloc_obj(struct ksmbd_user, KSMBD_DEFAULT_GFP); if (!user) return NULL; diff --git a/fs/smb/server/mgmt/user_session.c b/fs/smb/server/mgmt/user_session.c index 957a12de6a9d..39be2d2be86c 100644 --- a/fs/smb/server/mgmt/user_session.c +++ b/fs/smb/server/mgmt/user_session.c @@ -322,7 +322,7 @@ int ksmbd_session_rpc_open(struct ksmbd_session *sess, char *rpc_name) if (!method) return -EINVAL; - entry = kzalloc(sizeof(struct ksmbd_session_rpc), KSMBD_DEFAULT_GFP); + entry = kzalloc_obj(struct ksmbd_session_rpc, KSMBD_DEFAULT_GFP); if (!entry) return -ENOMEM; @@ -579,7 +579,7 @@ struct preauth_session *ksmbd_preauth_session_alloc(struct ksmbd_conn *conn, { struct preauth_session *sess; - sess = kmalloc(sizeof(struct preauth_session), KSMBD_DEFAULT_GFP); + sess = kmalloc_obj(struct preauth_session, KSMBD_DEFAULT_GFP); if (!sess) return NULL; @@ -663,7 +663,7 @@ static struct ksmbd_session *__session_create(int protocol) if (protocol != CIFDS_SESSION_FLAG_SMB2) return NULL; - sess = kzalloc(sizeof(struct ksmbd_session), KSMBD_DEFAULT_GFP); + sess = kzalloc_obj(struct ksmbd_session, KSMBD_DEFAULT_GFP); if (!sess) return NULL; diff --git a/fs/smb/server/oplock.c b/fs/smb/server/oplock.c index a5967ac46604..09d9878db9cb 100644 --- a/fs/smb/server/oplock.c +++ b/fs/smb/server/oplock.c @@ -34,7 +34,7 @@ static struct oplock_info *alloc_opinfo(struct ksmbd_work *work, struct ksmbd_session *sess = work->sess; struct oplock_info *opinfo; - opinfo = kzalloc(sizeof(struct oplock_info), KSMBD_DEFAULT_GFP); + opinfo = kzalloc_obj(struct oplock_info, KSMBD_DEFAULT_GFP); if (!opinfo) return NULL; @@ -93,7 +93,7 @@ static int alloc_lease(struct oplock_info *opinfo, struct lease_ctx_info *lctx) { struct lease *lease; - lease = kmalloc(sizeof(struct lease), KSMBD_DEFAULT_GFP); + lease = kmalloc_obj(struct lease, KSMBD_DEFAULT_GFP); if (!lease) return -ENOMEM; @@ -698,7 +698,7 @@ static int smb2_oplock_break_noti(struct oplock_info *opinfo) if (!work) return -ENOMEM; - br_info = kmalloc(sizeof(struct oplock_break_info), KSMBD_DEFAULT_GFP); + br_info = kmalloc_obj(struct oplock_break_info, KSMBD_DEFAULT_GFP); if (!br_info) { ksmbd_free_work_struct(work); return -ENOMEM; @@ -803,7 +803,7 @@ static int smb2_lease_break_noti(struct oplock_info *opinfo) if (!work) return -ENOMEM; - br_info = kmalloc(sizeof(struct lease_break_info), KSMBD_DEFAULT_GFP); + br_info = kmalloc_obj(struct lease_break_info, KSMBD_DEFAULT_GFP); if (!br_info) { ksmbd_free_work_struct(work); return -ENOMEM; @@ -1046,7 +1046,7 @@ static int add_lease_global_list(struct oplock_info *opinfo) } read_unlock(&lease_list_lock); - lb = kmalloc(sizeof(struct lease_table), KSMBD_DEFAULT_GFP); + lb = kmalloc_obj(struct lease_table, KSMBD_DEFAULT_GFP); if (!lb) return -ENOMEM; @@ -1491,7 +1491,7 @@ struct lease_ctx_info *parse_lease_state(void *open_req) if (IS_ERR_OR_NULL(cc)) return NULL; - lreq = kzalloc(sizeof(struct lease_ctx_info), KSMBD_DEFAULT_GFP); + lreq = kzalloc_obj(struct lease_ctx_info, KSMBD_DEFAULT_GFP); if (!lreq) return NULL; diff --git a/fs/smb/server/server.c b/fs/smb/server/server.c index c2c074346da1..c3f1b7219950 100644 --- a/fs/smb/server/server.c +++ b/fs/smb/server/server.c @@ -410,7 +410,7 @@ static int __queue_ctrl_work(int type) { struct server_ctrl_struct *ctrl; - ctrl = kmalloc(sizeof(struct server_ctrl_struct), KSMBD_DEFAULT_GFP); + ctrl = kmalloc_obj(struct server_ctrl_struct, KSMBD_DEFAULT_GFP); if (!ctrl) return -ENOMEM; diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c index cbb31efdbaa2..8a3e17fd4af9 100644 --- a/fs/smb/server/smb2pdu.c +++ b/fs/smb/server/smb2pdu.c @@ -1164,8 +1164,8 @@ int smb2_handle_negotiate(struct ksmbd_work *work) switch (conn->dialect) { case SMB311_PROT_ID: conn->preauth_info = - kzalloc(sizeof(struct preauth_integrity_info), - KSMBD_DEFAULT_GFP); + kzalloc_obj(struct preauth_integrity_info, + KSMBD_DEFAULT_GFP); if (!conn->preauth_info) { rc = -ENOMEM; rsp->hdr.Status = STATUS_INVALID_PARAMETER; @@ -1560,7 +1560,7 @@ binding_session: if (conn->dialect >= SMB30_PROT_ID) { chann = lookup_chann_list(sess, conn); if (!chann) { - chann = kmalloc(sizeof(struct channel), KSMBD_DEFAULT_GFP); + chann = kmalloc_obj(struct channel, KSMBD_DEFAULT_GFP); if (!chann) return -ENOMEM; @@ -1655,7 +1655,7 @@ binding_session: if (conn->dialect >= SMB30_PROT_ID) { chann = lookup_chann_list(sess, conn); if (!chann) { - chann = kmalloc(sizeof(struct channel), KSMBD_DEFAULT_GFP); + chann = kmalloc_obj(struct channel, KSMBD_DEFAULT_GFP); if (!chann) return -ENOMEM; @@ -7326,7 +7326,7 @@ static struct ksmbd_lock *smb2_lock_init(struct file_lock *flock, { struct ksmbd_lock *lock; - lock = kzalloc(sizeof(struct ksmbd_lock), KSMBD_DEFAULT_GFP); + lock = kzalloc_obj(struct ksmbd_lock, KSMBD_DEFAULT_GFP); if (!lock) return NULL; diff --git a/fs/smb/server/smbacl.c b/fs/smb/server/smbacl.c index 05598d994a68..49c2abb29bf5 100644 --- a/fs/smb/server/smbacl.c +++ b/fs/smb/server/smbacl.c @@ -417,7 +417,7 @@ static void parse_dacl(struct mnt_idmap *idmap, return; } - ppace = kmalloc_array(num_aces, sizeof(struct smb_ace *), KSMBD_DEFAULT_GFP); + ppace = kmalloc_objs(struct smb_ace *, num_aces, KSMBD_DEFAULT_GFP); if (!ppace) { free_acl_state(&default_acl_state); free_acl_state(&acl_state); @@ -603,7 +603,7 @@ static void set_posix_acl_entries_dacl(struct mnt_idmap *idmap, for (i = 0; i < fattr->cf_acls->a_count; i++, pace++) { int flags = 0; - sid = kmalloc(sizeof(struct smb_sid), KSMBD_DEFAULT_GFP); + sid = kmalloc_obj(struct smb_sid, KSMBD_DEFAULT_GFP); if (!sid) break; @@ -670,7 +670,7 @@ posix_default_acl: pace = fattr->cf_dacls->a_entries; for (i = 0; i < fattr->cf_dacls->a_count; i++, pace++) { - sid = kmalloc(sizeof(struct smb_sid), KSMBD_DEFAULT_GFP); + sid = kmalloc_obj(struct smb_sid, KSMBD_DEFAULT_GFP); if (!sid) break; @@ -930,7 +930,7 @@ int build_sec_desc(struct mnt_idmap *idmap, gid_t gid; unsigned int sid_type = SIDOWNER; - nowner_sid_ptr = kmalloc(sizeof(struct smb_sid), KSMBD_DEFAULT_GFP); + nowner_sid_ptr = kmalloc_obj(struct smb_sid, KSMBD_DEFAULT_GFP); if (!nowner_sid_ptr) return -ENOMEM; @@ -939,7 +939,7 @@ int build_sec_desc(struct mnt_idmap *idmap, sid_type = SIDUNIX_USER; id_to_sid(uid, sid_type, nowner_sid_ptr); - ngroup_sid_ptr = kmalloc(sizeof(struct smb_sid), KSMBD_DEFAULT_GFP); + ngroup_sid_ptr = kmalloc_obj(struct smb_sid, KSMBD_DEFAULT_GFP); if (!ngroup_sid_ptr) { kfree(nowner_sid_ptr); return -ENOMEM; diff --git a/fs/smb/server/transport_rdma.c b/fs/smb/server/transport_rdma.c index fb36fb9d5214..7c53b78b818e 100644 --- a/fs/smb/server/transport_rdma.c +++ b/fs/smb/server/transport_rdma.c @@ -411,7 +411,7 @@ static struct smb_direct_transport *alloc_transport(struct rdma_cm_id *cm_id) struct smbdirect_socket_parameters *sp; struct ksmbd_conn *conn; - t = kzalloc(sizeof(*t), KSMBD_DEFAULT_GFP); + t = kzalloc_obj(*t, KSMBD_DEFAULT_GFP); if (!t) return NULL; sc = &t->socket; @@ -1852,8 +1852,8 @@ static int smb_direct_rdma_xmit(struct smb_direct_transport *t, /* build rdma_rw_ctx for each descriptor */ desc_buf = buf; for (i = 0; i < desc_num; i++) { - msg = kzalloc(struct_size(msg, sg_list, SG_CHUNK_SIZE), - KSMBD_DEFAULT_GFP); + msg = kzalloc_flex(*msg, sg_list, SG_CHUNK_SIZE, + KSMBD_DEFAULT_GFP); if (!msg) { ret = -ENOMEM; goto out; @@ -2860,7 +2860,7 @@ static int smb_direct_ib_client_add(struct ib_device *ib_dev) if (!rdma_frwr_is_supported(&ib_dev->attrs)) return 0; - smb_dev = kzalloc(sizeof(*smb_dev), KSMBD_DEFAULT_GFP); + smb_dev = kzalloc_obj(*smb_dev, KSMBD_DEFAULT_GFP); if (!smb_dev) return -ENOMEM; smb_dev->ib_dev = ib_dev; diff --git a/fs/smb/server/transport_tcp.c b/fs/smb/server/transport_tcp.c index 2436dabada95..7e29b06820e2 100644 --- a/fs/smb/server/transport_tcp.c +++ b/fs/smb/server/transport_tcp.c @@ -61,7 +61,7 @@ static struct tcp_transport *alloc_transport(struct socket *client_sk) struct tcp_transport *t; struct ksmbd_conn *conn; - t = kzalloc(sizeof(*t), KSMBD_DEFAULT_GFP); + t = kzalloc_obj(*t, KSMBD_DEFAULT_GFP); if (!t) return NULL; t->sock = client_sk; @@ -156,7 +156,7 @@ static struct kvec *get_conn_iovec(struct tcp_transport *t, unsigned int nr_segs return t->iov; /* not big enough -- allocate a new one and release the old */ - new_iov = kmalloc_array(nr_segs, sizeof(*new_iov), KSMBD_DEFAULT_GFP); + new_iov = kmalloc_objs(*new_iov, nr_segs, KSMBD_DEFAULT_GFP); if (new_iov) { kfree(t->iov); t->iov = new_iov; @@ -636,7 +636,7 @@ static struct interface *alloc_iface(char *ifname) if (!ifname) return NULL; - iface = kzalloc(sizeof(struct interface), KSMBD_DEFAULT_GFP); + iface = kzalloc_obj(struct interface, KSMBD_DEFAULT_GFP); if (!iface) { kfree(ifname); return NULL; diff --git a/fs/smb/server/vfs_cache.c b/fs/smb/server/vfs_cache.c index e302e403e55a..ff4ea412d900 100644 --- a/fs/smb/server/vfs_cache.c +++ b/fs/smb/server/vfs_cache.c @@ -303,7 +303,7 @@ static struct ksmbd_inode *ksmbd_inode_get(struct ksmbd_file *fp) if (ci) return ci; - ci = kmalloc(sizeof(struct ksmbd_inode), KSMBD_DEFAULT_GFP); + ci = kmalloc_obj(struct ksmbd_inode, KSMBD_DEFAULT_GFP); if (!ci) return NULL; @@ -1126,7 +1126,7 @@ int ksmbd_reopen_durable_fd(struct ksmbd_work *work, struct ksmbd_file *fp) int ksmbd_init_file_table(struct ksmbd_file_table *ft) { - ft->idr = kzalloc(sizeof(struct idr), KSMBD_DEFAULT_GFP); + ft->idr = kzalloc_obj(struct idr, KSMBD_DEFAULT_GFP); if (!ft->idr) return -ENOMEM; |
